Mycobacteria have a distinct type of secretion system, termed type VII (T7SS), which is encoded by paralogous chromosomal loci (ESX) and associated with pathogenesis, conjugation, metal homeostasis and other functions. Gene duplication is an important mechanism by which novel gene functions can evolve. There are, however, potential conflicts between adaptive forces that stabilize duplicated genes and those that enable the evolution of new functions. Our objective was to delineate the adaptive forces underlying functional diversification of T7SS using genomic data from mycobacteria and related Actinobacteria. Plasmid-borne ESX were described recently, and we found evidence that the initial duplication and divergence of ESX systems occurred on plasmids and was driven by selection for advantageous mutations. We speculate that differentiation of plasmid ESX was driven by development of plasmid incompatibility systems. Plasmid ESX systems appear to have been repurposed following their migration to the chromosome, and there is evidence of positive selection driving further differentiation of the chromosomal ESX. We hypothesize that ESX loci were initially stabilized on the chromosome by mediating their own transfer. These results emphasize the diverse adaptive paths underlying the evolution of novelty, which in this case involved plasmid duplications, selection for advantageous mutations in both the core and mobile genomes, migration of the loci between plasmids and chromosomes, and lateral transfer among chromosomes. We discuss further implications of these results for the choice of model organism to study ESX functions in Mycobacterium tuberculosis.