Karst peak cluster depression areas are characterized by a special double-layer hydrogeological structure, and under the influence of human activities, there are many environmental problems, such as soil erosion, rocky desertification, dryness and wetness, and heavy metal pollution. How to clarify the spatial variations and influencing factor analysis of heavy metals in the soil of typical rocky desertification peak cluster depressions has become an important content to promote the prevention and control of heavy metal pollution in soil and the comprehensive management of rocky desertification. The typical rocky desertification peak cluster depression soil in Pingguo City, Guangxi, was selected as the research object in this study.Spatial variations, associated mechanisms and pollution risk assessments of eight heavy metals (e.g., As, Hg, Cr, Ni, Cu, Zn, Cd, and Pb) in soil were carried out by using the geo-statistical, geological accumulation index, potential ecological danger index and geographical detector methods. These results show that the spatial distribution of heavy metals in the study area generally shows a downward trend from northeast to southwest. Cr and Cd show medium spatial correlation, and the other six heavy metals show strong spatial correlation, which was analyzed by semivariogram. The study area is affected by different pollution levels of Cd, As, Cr, Cu and Zn, and the impact of Cd is the most important. The geological accumulation index and potential ecological hazard index of Cd are 1.34 and 107.73, respectively, but the average geological accumulation index of other heavy metals is less than 0, and the potential ecological hazard index is less than 16.The main factors affecting the spatial differentiation of eight heavy metals in the soil of the study area are pH, stratum, Fe2O3, land use, phosphorus, CaO, Mn, distance to fault and rocky desertification degree. Moreover, the interaction types of different factor groups on the spatial differentiation of heavy metals in soil were mainly two factors enhanced and nonlinear enhanced. Therefore, it is considered that different factors have different effects on the spatial differentiation characteristics of various heavy metals in the soil of rocky desertification peak cluster depression. Cd is the most serious heavy metal element in the soil pollution degree and potential ecological harm degree of rocky desertification peak cluster depression. Strata, Mn, CaO, lithology, distance to fault and phosphorus are the key factors affecting the spatial differentiation of Cd.