BackgroundHigh-altitude ecosystems are extreme environments that generate specific physiological, morphological, and behavioral adaptations in ectotherms. The shifts in gut microbiota of the ectothermic hosts as an adaptation to environmental changes are still largely unknown. We investigated the food ingested and the bacterial, fungal, and protistan communities in feces of the lizard Sceloporus grammicus inhabiting an altitudinal range using metabarcoding approaches.ResultsThe bacterial phyla Bacteroidetes and Firmicutes, and the genera Bacteroides and Parabacteroides dominated the core fecal bacteriome, while Zygomycota and Ascomycota, and the species Basidiobolus ranarum and Basidiobolus magnus dominated the core fecal mycobiome. The diet of S. grammicus included 29 invertebrate families belonging to Arachnida, Chilopoda, and Insecta. The diversity and abundance of its diet decreased sharply at high altitudes, while the abundance of plant material and Agaricomycetes was significantly higher at the highest site. The composition of the fecal microbiota of S. grammicus was different at the three altitudes, but not between females and males. Dietary restriction in S. grammicus at 4150 m might explain the high fecal abundance of Akkermansia and Oscillopira, bacteria characteristic of long fasting periods, while low temperature favored B. magnus. A high proportion of bacterial functions were digestive in S. grammicus at 2600 and 3100, while metabolism of aminoacids, vitamins, and key intermediates of metabolic pathways were higher at 4150 m. Different assemblages of fungal species in the lizard reflect differences in the environments at different elevations. Pathogens were more prevalent at high elevations than at the low ones.ConclusionsLimiting food resources at high elevations might oblige S. grammicus to exploit other food resources and its intestinal microbiota have degradative and detoxifying capacities. Sceloporus grammicus might have acquired B. ranarum from the insects infected by the fungus, but its commensal relationship might be established by the quitinolytic capacities of B. ranarum. The mycobiome participate mainly in digestive and degradative functions while the bacteriome in digestive and metabolic functions.