The gut microbiotas of zebrafish and mice share six bacterial divisions, although the specific bacteria within these divisions differ. To test how factors specific to host gut habitat shape microbial community structure, we performed reciprocal transplantations of these microbiotas into germ-free zebrafish and mouse recipients. The results reveal that communities are assembled in predictable ways. The transplanted community resembles its community of origin in terms of the lineages present, but the relative abundance of the lineages changes to resemble the normal gut microbial community composition of the recipient host. Thus, differences in community structure between zebrafish and mice arise in part from distinct selective pressures imposed within the gut habitat of each host. Nonetheless, vertebrate responses to microbial colonization of the gut are ancient: Functional genomic studies disclosed shared host responses to their compositionally distinct microbial communities and distinct microbial species that elicit conserved responses.