Related groups of microbes are widely distributed across Earth's habitats, implying numerous dispersal and adaptation events over evolutionary time. However, relatively little is known about the characteristics and mechanisms of these habitat transitions, particularly for populations that reside in animal microbiomes. Here, we review the literature concerning habitat transitions among a variety of bacterial and archaeal lineages, considering the frequency of migration events, potential environmental barriers, and mechanisms of adaptation to new physicochemical conditions, including the modification of protein inventories and other genomic characteristics. Cells dependent on microbial hosts, particularly bacteria from the Candidate Phyla Radiation, have undergone repeated habitat transitions from environmental sources into animal microbiomes. We compare their trajectories to those of both free-living cells—including the Melainabacteria, Elusimicrobia, and methanogenic archaea—and cellular endosymbionts and bacteriophages, which have made similar transitions. We conclude by highlighting major related topics that may be worthy of future study. Expected final online publication date for the Annual Review of Microbiology, Volume 77 is September 2023. Please see http://www.annualreviews.org/page/journal/pubdates for revised estimates.