The gut microbiota plays an integral role in the metabolism and immunity of animal hosts, and provides insights into the health and habitat assessment of threatened animals. The skywalker hoolock gibbon (Hoolock tianxing) is a newly described gibbon species, and is considered an endangered species. Here, we used 16S rRNA amplicon sequencing to describe the fecal bacterial community of skywalker hoolock gibbons from different habitats and in captivity. Fecal samples (n = 5) from two captive gibbons were compared with wild populations (N = 6 gibbons, n = 33 samples). At the phylum level, Spirochetes, Proteobacteria, Firmicutes, Bacteroidetes dominated in captive gibbons, while Firmicutes, Bacteroidetes, and Tenericutes dominated in wild gibbons. At the genus level, captive gibbons were dominated by Treponema-2, followed by Succinivibrio and Cerasicoccus, while wild gibbons were dominated by Anaeroplasma, Prevotellaceae UCG-001, and Erysipelotrichaceae UCG-004. Captive rearing was significantly associated with lower taxonomic alphadiversity, and different relative abundance of some dominant bacteria compared to wild gibbons. Predicted Kyoto Encyclopedia of Genes and Genomes pathway analyses showed that captive gibbons have significantly lower total pathway diversity and higher relative abundance of bacterial functions involved in "drug resistance: antimicrobial" and "carbohydrate metabolism" than wild gibbons. This study reveals the potential influence of captivity and habitat on the gut bacterial community of gibbons and provides a basis for guiding the conservation management of captive populations.