The energy frontier of particle physics is several trillion electron volts, but colliders capable of reaching this regime (such as the Large Hadron Collider and the International Linear Collider) are costly and time-consuming to build; it is therefore important to explore new methods of accelerating particles to high energies. Plasma-based accelerators are particularly attractive because they are capable of producing accelerating fields that are orders of magnitude larger than those used in conventional colliders1-3. In these accelerators, a drive beam (either laser or particle) produces a plasma wave (wakefield) that accelerates charged particles4-11. The ultimate utility of plasma accelerators will depend on sustaining ultrahigh accelerating fields over a substantial length to achieve a significant energy gain. Here we show that an energy gain of more than 42 GeV is achieved in a plasma wakefield accelerator of 85 cm length, driven by a 42 GeV electron beam at the Stanford Linear Accelerator Center (SLAC). The results are in excellent agreement with the predictions of three-dimensional particle-in-cell simulations. Most of the beam electrons lose energy to the plasma wave, but some electrons in the back of the same beam pulse are accelerated with a field of ∼52 GV m−1. This effectively doubles their energy, producing the energy gain of the 3-km-long SLAC accelerator in less than a metre for a small fraction of the electrons in the injected bunch. This is an important step towards demonstrating the viability of plasma accelerators for high-energy physics applications.