Spin resonance provides the high-energy resolution needed to determine biological and material structures by sensing weak magnetic interactions. In recent years, there have been notable achievements in detecting and coherently controlling individual atomic-scale spin centres for sensitive local magnetometry. However, positioning the spin sensor and characterizing spin-spin interactions with sub-nanometre precision have remained outstanding challenges. Here, we use individual Fe atoms as an electron spin resonance (ESR) sensor in a scanning tunnelling microscope to measure the magnetic field emanating from nearby spins with atomic-scale precision. On artificially built assemblies of magnetic atoms (Fe and Co) on a magnesium oxide surface, we measure that the interaction energy between the ESR sensor and an adatom shows an inverse-cube distance dependence (r â '3.01±0.04). This demonstrates that the atoms are predominantly coupled by the magnetic dipole-dipole interaction, which, according to our observations, dominates for atom separations greater than 1 nm. This dipolar sensor can determine the magnetic moments of individual adatoms with high accuracy. The achieved atomic-scale spatial resolution in remote sensing of spins may ultimately allow the structural imaging of individual magnetic molecules, nanostructures and spin-labelled biomolecules.