The first observation of the decays B(s)0→J/ψpp is reported, using proton-proton collision data corresponding to an integrated luminosity of 5.2 fb-1, collected with the LHCb detector. These decays are suppressed due to limited available phase space, as well as due to Okubo-Zweig-Iizuka or Cabibbo suppression. The measured branching fractions are B(B0→J/ψpp)=[4.51±0.40(stat)±0.44(syst)]×10-7, B(Bs0→J/ψpp)=[3.58±0.19(stat)±0.39(syst)]×10-6. For the Bs0 meson, the result is much higher than the expected value of O(10-9). The small available phase space in these decays also allows for the most precise single measurement of both the B0 mass as 5279.74±0.30(stat)±0.10(syst) MeV and the Bs0 mass as 5366.85±0.19(stat)±0.13(syst) MeV.