The hippocampus and the medial entorhinal cortex are part of a brain system that maps self-location during navigation in the proximal environment1,2. In this system, correlations between neural firing and an animal's position or orientation are so evident that cell types have been given simple descriptive names, such as place cells3, grid cells4, border cells5,6 and head-direction cells7. While the number of identified functional cell types is growing at a steady rate, insights remain limited by an almost-exclusive reliance on recordings from rodents foraging in empty enclosures that are different from the richly populated, geometrically irregular environments of the natural world. In environments that contain discrete objects, animals are known to store information about distance and direction to those objects and to use this vector information to guide navigation8-10. Theoretical studies have proposed that such vector operations are supported by neurons that use distance and direction from discrete objects11,12 or boundaries13,14 to determine the animal's location, but-although some cells with vector-coding properties may be present in the hippocampus15 and subiculum16,17-it remains to be determined whether and how vectorial operations are implemented in the wider neural representation of space. Here we show that a large fraction of medial entorhinal cortex neurons fire specifically when mice are at given distances and directions from spatially confined objects. These 'object-vector cells' are tuned equally to a spectrum of discrete objects, irrespective of their location in the test arena, as well as to a broad range of dimensions and shapes, from point-like objects to extended surfaces. Our findings point to vector coding as a predominant form of position coding in the medial entorhinal cortex.