For most mammals, including nonhuman primates, diet composition varies temporally in response to differences in food availability. Because diet influences gut microbiota composition, it is likely that the gut microbiota of wild mammals varies in response to seasonal changes in feeding patterns. Such variation may affect host digestive efficiency and, ultimately, host nutrition. In this study, we investigate the temporal variation in diet and gut microbiota composition and function in two groups (N = 13 individuals) of wild Mexican black howler monkeys (Alouatta pigra) over a 10-month period in Palenque National Park, Mexico. Temporal changes in the relative abundances of individual bacterial taxa were strongly correlated with changes in host diet. For example, the relative abundance of Ruminococcaceae was highest during periods when energy intake was lowest, and the relative abundance of Butyricicoccus was highest when young leaves and unripe fruit accounted for 68 % of the diet. Additionally, the howlers exhibited increased microbial production of energy during periods of reduced energy intake from food sources. Because we observed few changes in howler activity and ranging patterns during the course of our study, we propose that shifts in the composition and activity of the gut microbiota provided additional energy and nutrients to compensate for changes in diet. Energy and nutrient production by the gut microbiota appears to provide an effective buffer against seasonal fluctuations in energy and nutrient intake for these primates and is likely to have a similar function in other mammal species.