Head direction cells are critical for navigation because they convey information about which direction an animal is facing within an environment. To date, most studies on head direction encoding have been conducted on a horizontal two‐dimensional (2D) plane, and little is known about how three‐dimensional (3D) direction information is encoded in the brain despite humans and other animals living in a 3D world. Here, we investigated head direction encoding in the human brain while participants moved within a virtual 3D “spaceship” environment. Movement was not constrained to planes and instead participants could move along all three axes in volumetric space as if in zero gravity. Using functional magnetic resonance imaging (fMRI) multivoxel pattern similarity analysis, we found evidence that the thalamus, particularly the anterior portion, and the subiculum encoded the horizontal component of 3D head direction (azimuth). In contrast, the retrosplenial cortex was significantly more sensitive to the vertical direction (pitch) than to the azimuth. Our results also indicated that vertical direction information in the retrosplenial cortex was significantly correlated with behavioral performance during a direction judgment task. Our findings represent the first evidence showing that the “classic” head direction system that has been identified on a horizontal 2D plane also seems to encode vertical and horizontal heading in 3D space in the human brain.