The nitrogen-vacancy defect centre in diamond has potential applications in nanoscale electric and magnetic-field sensing, single-photon microscopy, quantum information processing and bioimaging. These applications rely on the ability to position a single nitrogen-vacancy centre within a few nanometres of a sample, and then scan it across the sample surface, while preserving the centre's spin coherence and readout fidelity. However, existing scanning techniques, which use a single diamond nanocrystal grafted onto the tip of a scanning probe microscope, suffer from short spin coherence times due to poor crystal quality, and from inefficient far-field collection of the fluorescence from the nitrogen-vacancy centre. Here, we demonstrate a robust method for scanning a single nitrogen-vacancy centre within tens of nanometres from a sample surface that addresses both of these concerns. This is achieved by positioning a single nitrogen-vacancy centre at the end of a high-purity diamond nanopillar, which we use as the tip of an atomic force microscope. Our approach ensures long nitrogen-vacancy spin coherence times (∼75µs), enhanced nitrogen-vacancy collection efficiencies due to waveguiding, and mechanical robustness of the device (several weeks of scanning time). We are able to image magnetic domains with widths of 25nm, and demonstrate a magnetic field sensitivity of 56nT Hz(-1/2) at a frequency of 33kHz, which is unprecedented for scanning nitrogen-vacancy centres.