The ability of an animal to locomote through its environment depends crucially on the interplay between its active endogenous control and the physics of its interactions with the environment. The nematode worm Caenorhabditis elegans serves as an ideal model system for studying the respective roles of neural control and biomechanics, as well as the interaction between them. With only 302 neurons in a hard-wired neural circuit, the worm's apparent anatomical simplicity belies its behavioural complexity. Indeed, C. elegans exhibits a rich repertoire of complex behaviors, the majority of which are mediated by its adaptive undulatory locomotion. The conventional wisdom is that two kinematically distinct C. elegans locomotion behaviors-swimming in liquids and crawling on dense gel-like media-correspond to distinct locomotory gaits. Here we analyze the worm's motion through a series of different media and reveal a smooth transition from swimming to crawling, marked by a linear relationship between key locomotion metrics. These results point to a single locomotory gait, governed by the same underlying control mechanism. We further show that environmental forces play only a small role in determining the shape of the worm, placing conditions on the minimal pattern of internal forces driving locomotion.