It is unclear if coexistence theory can be applied to gut microbiomes to understand their characteristics and modulate their composition. Through experiments in gnotobiotic mice with complex microbiomes, we demonstrated that strains of Akkermansia muciniphila and Bacteroides vulgatus could only be established if microbiomes were devoid of these species. Strains of A. muciniphila showed strict competitive exclusion, while B. vulgatus strains coexisted but populations were still influenced by competitive interactions. These differences in competitive behavior were reflective of genomic variation within the two species, indicating considerable niche overlap for A. muciniphila strains and a broader niche space for B. vulgatus strains. Priority effects were detected for both species as strains’ competitive fitness increased when colonizing first, which resulted in stable persistence of the A. muciniphila strain colonizing first and competitive exclusion of the strain arriving second. Based on these observations, we devised a subtractive strategy for A. muciniphila using antibiotics and showed that a strain from an assembled community can be stably replaced by another strain. By demonstrating that competitive outcomes in gut ecosystems depend on niche differences and are historically contingent, our study provides novel information to explain the ecological characteristics of gut microbiomes and a basis for their modulation.