Host-associated microbiomes are essential for a multitude of biological processes. Placed at the contact zone between external and internal environments, the little-studied oral microbiome has important roles in host physiology and health. Here we investigate the roles of host evolutionary relationships and ecology in shaping the oral microbiome in three closely related gorilla subspecies (mountain, Grauer’s, and western lowland gorillas) using shotgun metagenomics of 46 museum-preserved dental calculus samples. We find that the oral microbiomes of mountain gorillas are functionally and taxonomically distinct from the other two subspecies, despite close evolutionary relationships and geographic proximity with Grauer’s gorillas. Grauer’s gorillas show intermediate bacterial taxonomic and functional, and dietary profiles. Altitudinal differences in gorilla subspecies ranges appear to explain these patterns, suggesting a close connection between dental calculus microbiomes and the environment, likely mediated through dietary differences. This is further supported by the presence of gorilla subspecies-specific phyllosphere/rhizosphere taxa in the oral microbiome. Mountain gorillas show high abundance of nitrate-reducing oral taxa, which may promote adaptation to a high-altitude lifestyle by modulating blood pressure. Our results suggest that ecology, rather than evolutionary relationships and geographic distribution, shape the oral microbiome in these closely related species.