Nuclear spins serve as sensitive probes in chemistry1 and materials science2 and are promising candidates for quantum information processing3–6. 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 superconductors7,8 and spin liquids9 to quantum magnetism in nanomagnets10,11. 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 individually4,5,12. Strong nuclear spin polarization, known as hyperpolarization, can be achieved through hyperfine coupling with electron spins2. 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 nanoparticles13, and is harnessed for spin-based quantum information processing in quantum dots14 and doped silicon15–17. 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.