Magnetic imaging is a powerful tool for probing biological and physical systems. However, existing techniques either have poor spatial resolution compared to optical microscopy and are hence not generally applicable to imaging of sub-cellular structure (for example, magnetic resonance imaging1), or entail operating conditions that preclude application to living biological samples while providing submicrometre resolution (for example, scanning superconducting quantum interference device microscopy2, electron holography3 and magnetic resonance force microscopy4). Here we demonstrate magnetic imaging of living cells (magnetotactic bacteria) under ambient laboratory conditions and with sub-cellular spatial resolution (400 nanometres), using an optically detected magnetic field imaging array consisting of a nanometre-scale layer of nitrogen–vacancy colour centres implanted at the surface of a diamond chip. With the bacteria placed on the diamond surface, we optically probe the nitrogen–vacancy quantum spin states and rapidly reconstruct images of the vector components of the magnetic field created by chains of magnetic nanoparticles (magnetosomes) produced in the bacteria. We also spatially correlate these magnetic field maps with optical images acquired in the same apparatus. Wide-field microscopy allows parallel optical and magnetic imaging of multiple cells in a population with submicrometre resolution and a field of view in excess of 100 micrometres. Scanning electron microscope images of the bacteria confirm that the correlated optical and magnetic images can be used to locate and characterize the magnetosomes in each bacterium. Our results provide a new capability for imaging bio-magnetic structures in living cells under ambient conditions with high spatial resolution, and will enable the mapping of a wide range of magnetic signals within cells and cellular networks5, 6.