Imaging human brain function with techniques such as magnetoencephalography typically requires a subject to perform tasks while their head remains still within a restrictive scanner. This artificial environment makes the technique inaccessible to many people, and limits the experimental questions that can be addressed. For example, it has been difficult to apply neuroimaging to investigation of the neural substrates of cognitive development in babies and children, or to study processes in adults that require unconstrained head movement (such as spatial navigation). Here we describe a magnetoencephalography system that can be worn like a helmet, allowing free and natural movement during scanning. This is possible owing to the integration of quantum sensors, which do not rely on superconducting technology, with a system for nulling background magnetic fields. We demonstrate human electrophysiological measurement at millisecond resolution while subjects make natural movements, including head nodding, stretching, drinking and playing a ball game. Our results compare well to those of the current state-of-the-art, even when subjects make large head movements. The system opens up new possibilities for scanning any subject or patient group, with myriad applications such as characterization of the neurodevelopmental connectome, imaging subjects moving naturally in a virtual environment and investigating the pathophysiology of movement disorders.