Captivity is a key strategy for protecting endangered species, but research has primarily focused on artificial breeding and reintroduction to bolster wild populations, often overlooking the environmental and health risks associated with antibiotic resistance genes (ARGs). Here, we conducted a comprehensive analysis of the microbiome and ARG profiles in the gut of wild giant pandas across five representative populations, as well as one captive population, utilizing 16S rRNA gene sequencing and High-Throughput Quantitative PCR. Our findings revealed that both geographic location and captivity significantly influenced the gut microbial community and ARG composition in the gut of giant pandas. Additionally, we identified core microbiomes with essential ecological functions, particularly those related to food utilization, were identified in the giant panda gut across different regions. The gut ARGs in giant pandas exhibited a broad range of subtypes, with multidrug resistance genes being the most prevalent. Notably, the captive population harbored the highest abundance of high-risk ARGs, especially those conferring tetracycline resistance. High-risk multidrug ARGs (e.g., tolC, mepA, and mdtA) were found to be strongly correlated with the potential pathogens, such as Escherichia_Shigellina and Pseudomonas. Furthermore, bamboo-associated ARGs and mobile genetic elements (MGEs) contributed significantly to the ARG abundance in the giant panda gut, indicating that diet plays a crucial role in shaping gut resistome. Collectively, our study provides a detailed mapping of giant panda gut microbiomes and ARG distribution, offering valuable insights for conservation efforts and advancing our understanding of ARG dynamics in giant panda populations.