Two types of neurons in the rat brain have been proposed to participate in spatial learning and navigation: place cells, which fire selectively in specific locations of an environment and which may constitute key elements of cognitive maps, and head direction cells, which fire selectively when the rat's head is pointed in a specific direction and which may serve as an internal compass to orient the cognitive map. The spatially and directionally selective properties of these cells arise from a complex interaction between input from external landmarks and from idiothetic cues; however, the exact nature of this interaction is poorly understood. To address this issue, directional information from visual landmarks was placed in direct conflict with directional information from idiothetic cues. When the mismatch between the two sources of information was small (45 degrees), the visual landmarks had robust control over the firing properties of place cells; when the mismatch was larger, however, the firing fields of the place cells were altered radically, and the hippocampus formed a new representation of the environment. Similarly, the visual cues had control over the firing properties of head direction cells when the mismatch was small (45 degrees), but the idiothetic input usually predominated over the visual landmarks when the mismatch was larger. Under some conditions, when the visual landmarks predominated after a large mismatch, there was always a delay before the visual cues exerted their control over head direction cells. These results support recent models proposing that prewired intrinsic connections enable idiothetic cues to serve as the primary drive on place cells and head direction cells, whereas modifiable extrinsic connections mediate a learned, secondary influence of visual landmarks.