Protein secretion systems drive bacterial virulence, symbiosis and competition. Some components of these systems have homologs in other systems and/or other cellular appendages. This suggests extensive evolutionary tinkering of the molecular components of secretion systems and other complex cellular membrane machineries. The non-flagellar type 3 secretion system (NF-T3SS) allows the direct injection of proteic effectors into eukaryotic cells, and is involved in both beneficial (symbiosis) and antagonist (pathogenicity) relationships between bacteria and eukaryotes. This system is partly homologous to the bacterial flagellum. We developed tools to detect NF-T3SS in genomes, and used phylogenomics and comparative genomics to study the evolution of this system. We show that the NF-T3SS derived from a flagellar ancestor in a series of steps, each representing accretions to the system of proteins from other molecular machines. Surprisingly, we found a new intermediate conserved system in myxococcales, which emerged from the ancestral NF-T3SS and is neither a direct protein delivery system nor a flagellum. Direct protein delivery by NF-T3SS resulted from a long process of protein recruitment, diversification and adaptation to different types of host cell envelopes, i.e. vegetal and animal. This study and ongoing work should help deciphering the common evolutionary history of the different secretion systems. It also sheds light on the patterns of evolution of large molecular structures driving antagonistic and symbiotic ecological interactions.