Nuclear spins serve as sensitive probes in chemistry and materials science and are promising candidates for quantum information processing. NMR, the resonant control of nuclear spins, is a powerful tool for probing local magnetic environments in condensed matter systems, which range from magnetic ordering in high-temperature superconductors and spin liquids to quantum magnetism in nanomagnets. Increasing the sensitivity of NMR to the single-atom scale is challenging as it requires a strong polarization of nuclear spins, well in excess of the low polarizations obtained at thermal equilibrium, as well as driving and detecting them individually. Strong nuclear spin polarization, known as hyperpolarization, can be achieved through hyperfine coupling with electron spins. The fundamental mechanism is the conservation of angular momentum: an electron spin flips and a nuclear spin flops. The nuclear hyperpolarization enables applications such as in vivo magnetic resonance imaging using nanoparticles, and is harnessed for spin-based quantum information processing in quantum dots and doped silicon. Here we polarize the nuclear spins of individual copper atoms on a surface using a spin-polarized current in a scanning tunnelling microscope. By employing the electron–nuclear flip-flop hyperfine interaction, the spin angular momentum is transferred from tunnelling electrons to the nucleus of individual Cu atoms. The direction and magnitude of the nuclear polarization is controlled by the direction and amplitude of the current. The nuclear polarization permits the detection of the NMR of individual Cu atoms, which is used to sense the local magnetic environment of the Cu electron spin.