The Standard Model of particle physics assumes that the so-called fundamental constants are universal and unchanging. Absorption lines arising in molecular clouds along quasar sightlines offer a precise test for variations in the proton-to-electron mass ratio, µ, over cosmological time and distance scales. The inversion transitions of ammonia are particularly sensitive to µ as compared to molecular rotational transitions. Comparing the available ammonia spectra observed toward the quasar B0218+357 with new, high-quality rotational spectra, we present the first detailed measurement of µ with this technique, limiting relative deviations from the laboratory value to |Δµ/µ| < 1.8 x 10–6 (95% confidence level) at approximately half the universe's current age—the strongest astrophysical constraint to date. Higher-quality ammonia observations will reduce both the statistical and systematic uncertainties in these observations.