The giant panda is endemic to China. It is found in small, fragmented populations in six mountainous regions in the country, mainly in Sichuan, and also in neighbouring Shaanxi and Gansu. Successful habitat preservation has seen a rise in panda numbers, though loss of habitat due to human activities remains its biggest threat. In areas with a high concentration of medium-to-large-sized mammals—such as domestic cattle, a species known to degrade the landscape—the giant panda population is generally low. This is mainly attributed to the panda's avoidance of interspecific competition.
The species has been located at elevations of 2,400 to 3,000 m (7,900 to 9,800 ft) above sea level. They frequent habitats with a healthy concentration of bamboos, typically old-growth forests, but may also venture into secondary forest habitats. The Daxiangling Mountain population inhabits both coniferous and broadleaf forests. Additionally, the Qinling population often selects evergreen broadleaf and conifer forests, while pandas in the Qionglai mountainous region exclusively select upland conifer forests. The remaining two populations, namely those occurring in the Liangshan and Xiaoxiangling mountains, predominantly occur in broadleaf evergreen and conifer forests.
Giant pandas once roamed across Southeast Asia from Myanmar to northern Vietnam. Their range in China spanned much of the southeast region. By the Pleistocene, climate change affected panda populations, and the subsequent domination of modern humans led to large-scale habitat loss. In 2001, it was estimated that the range of the giant panda had declined by about 99% of its range in earlier millenniums.