Recent mass measurements of light atomic nuclei in Penning traps have indicated possible inconsistencies in closely related physical constants such as the proton-electron and deuteron-proton mass ratios. These quantities also influence the predicted vibrational spectrum of the deuterated molecular hydrogen ion (HD+) in its electronic ground state. We used Doppler-free two-photon laser spectroscopy to measure the frequency of the v = 0→9 overtone transition (v, vibrational quantum number) of this spectrum with an uncertainty of 2.9 parts per trillion. By leveraging high-precision ab initio calculations, we converted our measurement to tight constraints on the proton-electron and deuteron-proton mass ratios, consistent with the most recent Penning trap determinations of these quantities. This results in a precision of 21 parts per trillion for the value of the proton-electron mass ratio.