While research into the biology of animal behaviour has primarily focused on the central nervous system, cues from peripheral tissues and the environment have been implicated in brain development and function1. There is emerging evidence that bidirectional communication between the gut and the brain affects behaviours including anxiety, cognition, nociception and social interaction1-9. Coordinated locomotor behaviour is critical for the survival and propagation of animals, and is regulated by internal and external sensory inputs10,11. However, little is known about how the gut microbiome influences host locomotion, or the molecular and cellular mechanisms involved. Here we report that germ-free status or antibiotic treatment results in hyperactive locomotor behaviour in the fruit fly Drosophila melanogaster. Increased walking speed and daily activity in the absence of a gut microbiome are rescued by mono-colonization with specific bacteria, including the fly commensal Lactobacillus brevis. The bacterial enzyme xylose isomerase from L. brevis recapitulates the locomotor effects of microbial colonization by modulating sugar metabolism in flies. Notably, thermogenetic activation of octopaminergic neurons or exogenous administration of octopamine, the invertebrate counterpart of noradrenaline, abrogates the effects of xylose isomerase on Drosophila locomotion. These findings reveal a previously unappreciated role for the gut microbiome in modulating locomotion, and identify octopaminergic neurons as mediators of peripheral microbial cues that regulate motor behaviour in animals.