Bacteria glide across solid surfaces by mechanisms that have remained largely mysterious despite decades of research. In the deltaproteobacterium Myxococcus xanthus, this locomotion allows the formation stress-resistant fruiting bodies where sporulation takes place. However, despite the large number of genes identified as important for gliding, no specific machinery has been identified so far, hampering in-depth investigations. Based on the premise that components of the gliding machinery must have co-evolved and encode both envelope-spanning proteins and a molecular motor, we re-annotated known gliding motility genes and examined their taxonomic distribution, genomic localization, and phylogeny. We successfully delineated three functionally related genetic clusters, which we proved experimentally carry genes encoding the basal gliding machinery in M. xanthus, using genetic and localization techniques. For the first time, this study identifies structural gliding motility genes in the Myxobacteria and opens new perspectives to study the motility mechanism. Furthermore, phylogenomics provide insight into how this machinery emerged from an ancestral conserved core of genes of unknown function that evolved to gliding by the recruitment of functional modules in Myxococcales. Surprisingly, this motility machinery appears to be highly related to a sporulation system, underscoring unsuspected common mechanisms in these apparently distinct morphogenic phenomena.