The gut microbiome, or the community of microorganisms inhabiting the digestive tract, is often unique to its symbiont and, in many animal taxa, is highly influenced by host phylogeny and diet. In this study, we characterized the gut microbiome of the African savanna elephant (Loxodonta africana) and the African forest elephant (Loxodonta cyclotis), sister taxa separated by 2.6–5.6 million years of independent evolution. We examined the effect of host phylogeny on microbiome composition. Additionally, we examined the influence of habitat types (forest versus savanna) and diet types (crop‐raiding versus noncrop‐raiding) on the microbiome within L. africana. We found 58 bacterial orders, representing 16 phyla, across all African elephant samples. The most common phyla were Firmicutes, Proteobacteria, and Bacteroidetes. The microbiome of L. africana was dominated by Firmicutes, similar to other hindgut fermenters, while the microbiome of L. cyclotis was dominated by Proteobacteria, similar to more frugivorous species. Alpha diversity did not differ across species, habitat type, or diet, but beta diversity indicated that microbial communities differed significantly among species, diet types, and habitat types. Based on predicted KEGG metabolic pathways, we also found significant differences between species, but not habitat or diet, in amino acid metabolism, energy metabolism, and metabolism of terpenoids and polyketides. Understanding the digestive capabilities of these elephant species could aid in their captive management and ultimately their conservation.