It is well established that neural circuits consist of a great diversity of cell types, but very little is known about how neuronal diversity contributes to cognition and behavior. One approach to addressing this problem is to directly link cellular diversity to neuronal activity recorded in vivo in behaving animals. Here we describe the technical procedures for obtaining juxtacellular recordings from single neurons in trained rats engaged in exploratory behavior. The recorded neurons can be labeled to allow subsequent anatomical identification. In its current format, the protocol can be used for resolving the cellular identity of spatially modulated neurons (i.e., head-direction cells and grid cells), which form the basis of the animal's internal representation of space, but this approach can easily be extended to other unrestrained behaviors. The procedures described here, from the beginning of animal training to the histological processing of brain sections, can be completed in ≈ 3-4 weeks.