It has long been recognized that the mammalian gut microbiota has a role in the development and activation of the host immune system. Much less is known on how host immunity regulates the gut microbiota. Here we investigated the role of adaptive immunity on the mouse distal gut microbial composition by sequencing 16 S rRNA genes from microbiota of immunodeficient Rag1(-/-) mice, versus wild-type mice, under the same housing environment. To detect possible interactions among immunological status, age and variability from anatomical sites, we analyzed samples from the cecum, colon, colonic mucus and feces before and after weaning. High-throughput sequencing showed that Firmicutes, Bacteroidetes and Verrucomicrobia dominated mouse gut bacterial communities. Rag1(-) mice had a distinct microbiota that was phylogenetically different from wild-type mice. In particular, the bacterium Akkermansia muciniphila was highly enriched in Rag1(-/-) mice compared with the wild type. This enrichment was suppressed when Rag1(-/-) mice received bone marrows from wild-type mice. The microbial community diversity increased with age, albeit the magnitude depended on Rag1 status. In addition, Rag1(-/-) mice had a higher gain in microbiota richness and evenness with increase in age compared with wild-type mice, possibly due to the lack of pressure from the adaptive immune system. Our results suggest that adaptive immunity has a pervasive role in regulating gut microbiota's composition and diversity.