We developed an energy landscape to understand the physical principles of probabilistic locomotor transitions in complex 3D terrain. For a model system of cockroaches traversing beam-like obstacles, using animal experiments and robotic physical modelling, we demonstrated that locomotor transitions of animals and robots on complex 3-D terrain correspond to barrier-crossing transitions on a potential energy landscape. We discovered that locomotor modes are attracted to energy basins on landscape separated by potential energy barriers. Kinetic energy fluctuation from oscillatory self-propulsion helps the system stochastically escape from one basin and reach another to make transitions. We also found that escape is more likely toward lower barrier direction. Our energy landscape approach from first principles helps understand how multipathway transitions across locomotor modes statistically emerge from physical interaction with the complex terrain.