The intestinal microbiota assumes a pivotal role in modulating host metabolism, immune responses, overall health, and additional physiological dimensions. The structural and functional characteristics of the intestinal microbiota may cause alterations within the host’s body to a certain extent. The composition of the gut microbiota is associated with environmental factors, dietary habits, and other pertinent conditions. The investigation into the gut microbiota of yaks remained relatively underexplored. An examination of yak gut microbiota holds promise in elucidating the complex relationship between microbial communities and the adaptive responses of the host to its environment. In this study, yak were selected from two distinct environmental conditions: those raised in sheds (NS, n=6) and grazed in Nimu County (NF, n=6). Fecal samples were collected from the yaks and subsequently processed for analysis through 16S rDNA and ITS sequencing methodologies. The results revealed that different feeding styles result in significant differences in the Alpha diversity of fungi in the gut of yaks, while the gut microbiota of captive yaks was relatively conserved. In addition, significant differences appeared in the abundance of microorganisms in different taxa, phylum Verrucomicrobiota was significantly enriched in group NF while Firmicutes was higher in group NS. At the genus level, Akkermansia, Paenibacillus, Roseburia, Dorea, UCG_012, Anaerovorax and Marvinbryantia were enriched in group NF while Desemzia, Olsenella, Kocuria, Ornithinimicrobium and Parvibacter were higher in group NS (P