The molecular hydrogen ions (MHI) are three-body systems suitable for advancing our knowledge in several domains: fundamental constants, tests of quantum physics, search for new interparticle forces, tests of the weak equivalence principle1 and, once the anti-molecule \(\overline{p}\,\overline{p}\,{e}^{+}\) becomes available, new tests of charge–parity–time-reversal invariance and local position invariance1–3. To achieve these goals, high-accuracy laser spectroscopy of several isotopologues, in particular \({{\rm{H}}}_{2}^{+}\) , is required4. Here we present a Doppler-free laser spectroscopy of a \({{\rm{H}}}_{2}^{+}\) rovibrational transition, achieving line resolutions as large as 2.2 × 1013. We accurately determine the transition frequency with 8 × 10−12 fractional uncertainty. We also determine the spin–rotation coupling coefficient with 0.1 kHz uncertainty and its value is consistent with the state-of-the-art theory prediction5. The combination of our theoretical and experimental \({{\rm{H}}}_{2}^{+}\) data allows us to deduce a new value for the proton-electron mass ratio mp/me. It is in agreement with the value obtained from mass spectrometry and has 2.3 times lower uncertainty. From combined MHI, H/D and muonic H/D data, we determine the baryon mass ratio md/mp with 1.1 × 10−10 absolute uncertainty. The value agrees with the directly measured mass ratio6. Finally, we present a match between a theoretical prediction and an experimental result, with a fractional uncertainty of 8.1 × 10−12. Both results indicate a notable confirmation of the predictive power of quantum theory and the absence of beyond-the-standard-model effects at these levels.