Qubits, the quantum mechanical bits required for quantum computing, must retain their quantum states for times long enough to allow the information contained in them to be processed. In many types of electron-spin qubits, the primary source of information loss is decoherence due to the interaction with nuclear spins of the host lattice. For electrons in gate-defined GaAs quantum dots, spin-echo measurements have revealed coherence times of about 1 µs at magnetic fields below 100 mT (refs 1,2). Here, we show that coherence in such devices can survive much longer, and provide a detailed understanding of the measured nuclearspin-induced decoherence. At fields above a few hundred millitesla, the coherence time measured using a singlepulse spin echo is 30 µs. At lower fields, the echo first collapses, but then revives at times determined by the relative Larmor precession of different nuclear species. This behaviour was recently predicted 3,4 , and can, as we show, be quantitatively accounted for by a semiclassical model for the dynamics of electron and nuclear spins. Using a multiple-pulse Carr-Purcell-Meiboom-Gill echo sequence, the decoherence time can be extended to more than 200 µs, an improvement by two orders of magnitude compared with previous measurements 1,2,5 .The promise of quantum-dot spin qubits as a solid-state approach to quantum computing is demonstrated by the successful realization of initialization, control and single-shot readout of electron-spin qubits in GaAs quantum dots using optical 6 , magnetic 7 and fully electrical 8-10 techniques. To further advance spin-based quantum computing, it is vital to mitigate decoherence due to the interaction of the electron spin with the spins of nuclei of the host material. Understanding the dynamics of this system is also of great fundamental interest 11,12 .Through the hyperfine interaction, an electron spin in a GaAs quantum dot is subjected to an effective magnetic field produced by the nuclear spins. Under typical experimental conditions, this so-called 'Overhauser field' has a random magnitude and direction. Typically, measurements of the coherent electron-spin precession involve averaging over many experimental runs, and thus over many Overhauser field configurations. As a result, the coherence signal is suppressed for evolution times τ ∼ > T 2 * ≈ 10 ns (refs 1, 2). However, the nuclear spins evolve much more slowly than the electron spins, so that the Overhauser field is nearly static over sufficiently short time intervals. Therefore, one can partially eliminate the effect of the random nuclear field by flipping the electron spin halfway through an interval of free precession, a procedure known as Hahn echo. The random contributions of the Overhauser field to the electron-spin precession before and after the spin reversal then approximately cancel out. For longer evolution times, the effective field acting on the electron spin generally changes over the precession interval. This change leads to an eventual loss of coherence on a timescale determined ...