Electron spins in semiconductor structures are quantum bits with good prospects, but the information stored in the spin states tends to degrade quickly owing to interactions with nuclei in the host material. A study of GaAs quantum dots now provides a fuller understanding of this memory loss and how it can be suppressed. Quantum-memory times exceeding 200 μs are demonstrated, two orders of magnitude longer than previously reported for this system. 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 nuclear-spin-induced decoherence. At fields above a few hundred millitesla, the coherence time measured using a single-pulse 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 predicted3,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–Gillecho sequence, the decoherence time can be extended to more than 200 μs, an improvement by two orders of magnitude compared with previous measurements1,2,5.