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 × 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.