The medial entorhinal cortex is part of a neural system for mapping the position of an individual within a physical environment 1 . Grid cells, a key component of this system, fire in a characteristic hexagonal pattern of locations 2 , and are organized in modules 3 that collectively form a population code for the animal’s allocentric position 1 . The invariance of the correlation structure of this population code across environments 4,5 and behavioural states 6,7 , independent of specific sensory inputs, has pointed to intrinsic, recurrently connected continuous attractor networks (CANs) as a possible substrate of the grid pattern 1,8–11 . However, whether grid cell networks show continuous attractor dynamics, and how they interface with inputs from the environment, has remained unclear owing to the small samples of cells obtained so far. Here, using simultaneous recordings from many hundreds of grid cells and subsequent topological data analysis, we show that the joint activity of grid cells from an individual module resides on a toroidal manifold, as expected in a two-dimensional CAN. Positions on the torus correspond to positions of the moving animal in the environment. Individual cells are preferentially active at singular positions on the torus. Their positions are maintained between environments and from wakefulness to sleep, as predicted by CAN models for grid cells but not by alternative feedforward models 12 . This demonstration of network dynamics on a toroidal manifold provides a population-level visualization of CAN dynamics in grid cells.