Virtual reality (VR) environments are increasingly used to study spatial navigation in rodents. So far behavioral paradigms in virtual realities have been limited to linear tracks or open fields. However, little is known whether rodents can learn to navigate in more complex virtual spaces. We used a VR setup with a spherical treadmill but no head-fixation, which permits animals not only to move in a virtual environment but also to freely rotate around their vertical body axis. We trained Mongolian gerbils to perform spatial tasks in virtual mazes of different complexity. Initially the animals learned to run back and forth between the two ends of a virtual linear track for food reward. Performance, measured as path length and running time between the virtual reward locations, improved to asymptotic performance within about five training sessions. When more complex mazes were presented after this training epoch, the animals generalized and explored the new environments already at their first exposure. In a final experiment, the animals also learned to perform a two-alternative forced choice task in a virtual Y-maze. Our data thus shows that gerbils can be trained to solve spatial tasks in virtual mazes and that this behavior can be used as a readout for psychophysical measurements.