The rumen microbiome is thought to play an important role in maintaining normal gastrointestinal metabolism and nutrient absorption in ruminants. The present study was designed to investigate the effect of heat stress on the rumen microbiome of goats using 16S rRNA sequencing technology. Six female goats were randomly allocated into two control metabolic chambers: A and B (in which the temperature and humidity could be precisely controlled with a precision deviation of ± 0.5°C and ± 5%, with three goats/chamber). Dynamic changes in the rumen bacterial community were detected under 16 gradually increasing temperature and humidity indexes (THIs). Heat stress had no significant effect on alpha diversity but affected the main phyla and genera of the goat rumen microbiota. With a deeper level of heat stress, the TH groups formed a distinct cluster that differed from that of the control check (CK) group. The dominant phylum transitioned from Firmicutes to Bacteroidetes, and co-exclusion occurred between these two phyla. With the increase in THI, the content of probiotics in the Lachnospiraceae_ND3007_group (P < 0.05) decreased, and the abundance of pathogenic bacteria, such as Erysipelotrichaceae_UCG-004 and Treponema_2, increased; however, the difference between the groups was not significant (P > 0.05). Phylogenetic investigation of communities by reconstruction of unobserved states (PICRUSt) was used to predict bacterial function, and we found that the ambient environment significantly affected the balance between carbohydrate and energy metabolism (P < 0.05). In conclusion, heat stress changed the composition of rumen microbes and affected metabolic function. This experiment provides a theoretical basis for exploring the effects of environmental factors on the rumen of goats.