In 1928, Dirac published an equation(1) that combined quantum mechanics and special relativity. Negative-energy solutions to this equation, rather than being unphysical as initially thought, represented a class of hitherto unobserved and unimagined particles-antimatter. The existence of particles of antimatter was confirmed with the discovery of the positron(2) (or anti-electron) by Anderson in 1932, but it is still unknown why matter, rather than antimatter, survived after the Big Bang. As a result, experimental studies of antimatter(3-7), including tests of fundamental symmetries such as charge-parity and charge-parity-time, and searches for evidence of primordial antimatter, such as antihelium nuclei, have high priority in contemporary physics research. The fundamental role of the hydrogen atom in the evolution of the Universe and in the historical development of our understanding of quantum physics makes its antimatter counterpart-the antihydrogen atom-of particular interest. Current standard-model physics requires that hydrogen and antihydrogen have the same energy levels and spectral lines. The laser-driven 1S-2S transition was recently observed(8) in antihydrogen. Here we characterize one of the hyperfine components of this transition using magnetically trapped atoms of antihydrogen and compare it to model calculations for hydrogen in our apparatus. We find that the shape of the spectral line agrees very well with that expected for hydrogen and that the resonance frequency agrees with that in hydrogen to about 5 kilohertz out of 2.5 x 10(15) hertz. This is consistent with charge-parity-time invariance at a relative precision of 2 x 10(-12)-two orders of magnitude more precise than the previous determination(8)-corresponding to an absolute energy sensitivity of 2 x 10(-20) GeV.