The long-tailed goral is close to extinction, and ex situ conservation is essential to prevent this phenomenon. Studies on the gut microbiome of the long-tailed goral are important for understanding the ecology of this species. We amplified DNA from the 16S rRNA regions and compared the microbiomes of wild long-tailed gorals and two types of captive long-tailed gorals. Our findings revealed that the gut microbiome diversity of wild long-tailed gorals is greatly reduced when they are reared in captivity. A comparison of the two types of captive long-tailed gorals confirmed that animals with a more diverse diet exhibit greater gut microbiome diversity. Redundancy analysis confirmed that wild long-tailed gorals are distributed throughout the highlands, midlands, and lowlands. For the first time, it was revealed that the long-tailed goral are divided into three groups depending on the height of their habitat, and that the gut bacterial community changes significantly when long-tailed gorals are raised through ex situ conservation. This provides for the first time a perspective on the diversity of food plants associated with mountain height that will be available to long-tailed goral in the future.