Horizontal gene transfer is central to microbial evolution, because it enables genetic regions to spread horizontally through diverse communities. However, how gene transfer exerts such a strong effect is not understood. Here we develop an eco-evolutionary model and show how genetic transfer, even when rare, can transform the evolution and ecology of microbes. We recapitulate existing models, which suggest that asexual reproduction will overpower horizontal transfer and greatly limit its effects. We then show that allowing immigration completely changes these predictions. With migration, the rates and impacts of horizontal transfer are greatly increased, and transfer is most frequent for loci under positive natural selection. Our analysis explains how ecologically important loci can sweep through competing strains and species. In this way, microbial genomes can evolve to become ecologically diverse where different genomic regions encode for partially overlapping, but distinct, ecologies. Under these conditions ecological species do not exist, because genes, not species, inhabit niches.