Ordinary radio pulsars are neutron stars with magnetic fields of ~1012 gauss and spin periods in the range 0.1 to 3 seconds. In contrast, millisecond radio pulsars have much weaker fields (~109 gauss) and faster, millisecond spin rates. For both types of pulsar, the energy driving the radio pulsations is thought to be derived from the rotation of the neutron star. The star gradually `spins down' as energy is radiated away. Millisecond radio pulsars are often located in binary systems. In a widely accepted theoretical model,, they started as ordinary pulsars which lost most of their magnetic field and were `spun up' to millisecond periods by the accretion of matter from a companion star in an X-ray binary system. Evidence for this model has gradually mounted, but direct proof-in the form of the predicted coherent millisecond X-ray pulsations in the persistent flux of an X-ray binary has been lacking, despite many searches. Here we report the discovery of such a pulsar, confirming theoretical expectations. The source will probably become a millisecond radio pulsar when the accretion turns off completely.