Nitrogen doped Mg2TiO4 spinel, i.e. Mg2TiO4−xNy, has been synthesized and investigated as a photocatalyst for antibacterial activity. Mg2TiO4−xNy demonstrates superior photocatalytic activity for E. coli disinfection under visible light illumination (λ ≥ 400 nm). Complete disinfection of E. coli at a bacterial cell density of 1.0 × 107 CFU mL−1 can be achieved within merely 60 min. Mg2TiO4−xNy is capable of generating superoxide radicals (•O2−) under visible light illumination which are the reactive oxygen species (ROSs) for bacteria disinfection. DFT calculations have verified the importance of nitrogen dopants in improving the visible light sensitivity of Mg2TiO4−xNy. The facile synthesis, low cost, good biocompatibility and high disinfection activity of Mg2TiO4−xNy warrant promising applications in the field of water purification and antibacterial products.