Motor neurons are the final stage of neural processing for the execution of motor behaviours. Traditionally, motor neurons have been viewed as the 'final common pathway', serving as passive recipients merely conveying to the muscles the final motor program generated by upstream interneuron circuits. Here we reveal an unforeseen role of motor neurons in controlling the locomotor circuit function via gap junctions in zebrafish. These gap junctions mediate a retrograde analogue propagation of voltage fluctuations from motor neurons to control the synaptic release and recruitment of the upstream V2a interneurons that drive locomotion. Selective inhibition of motor neurons during ongoing locomotion de-recruits V2a interneurons and strongly influences locomotor circuit function. Rather than acting as separate units, gap junctions unite motor neurons and V2a interneurons into functional ensembles endowed with a retrograde analogue computation essential for locomotor rhythm generation. These results show that motor neurons are not a passive recipient of motor commands but an integral component of the neural circuits responsible for motor behaviour.