ALTHOUGH neutron stars are generally believed to be born with intense (1011-1013 G) magnetic fields1,2, which then gradually decay3, measurements of their field strengths remain uncertain. In the special case of X-ray-emitting binary pulsars, a direct estimate of the field strength can be obtained by measuring the energy of spectral features that are due to electron cyclotron resonance4-13. With the Ginga satellite observatory14,15, we have measured a cyclotron feature in the hard X-ray spectrum of the 1.24-s binary pulsar Hercules X-1 with a much greater energy resolution than in previous observations4-9. The spectrum from 10-60 keV can be described with a simple analytical formula12,16,17, which indicates an absorption feature at ~34 keV rather than an emission feature at ~50keV. From this we estimate the surface magnetic field strength of Her X-1 to be (2.9+/-0.3) × 1012 G.