To investigate the content, spatial distribution characteristics, and ecological risk status of soil heavy metals in different geological backgrounds, we selected three townships in Xingyi City, Guizhou Province, which have high background values of soil heavy metals, as the study area, and divided them into three geological background zones (carbonatite zone, carbonatite interspersed with clastic rock zone, and clastic rock zone). We analyzed the contents and spatial distributions of soil heavy metals As, Cd, Cr, Cu, Ni, Pb, and Zn in 187 soil samples from different geological background areas. The pollution index and potential ecological risk index were used to evaluate the level of soil pollution and ecological risks. The results showed that: (1) compared with the soil background values in Guizhou Province, all seven heavy metals were enriched in the carbonatite zone, especially for As and Cd. As, Cr, Cu, Ni and Zn were enriched in the carbonatite interbedded with clastic rock zone except for the depletion of Cd and Pb. All the seven heavy metals in the soil in the clastic rock zone showed depletion. (2) The spatial distribution of soil heavy metals was constrained by the geological background as well as the mining area. The spatial distribution pattern of As, Cd, Pb and Zn was similar, with their contents showing the carbonatite zone > carbonatite interbedded with clastic rock zone > clastic zone, which was mainly controlled by geological background. The spatial distribution of Cr, Cu and Ni was also similar, showing the carbonatite with clastic rock zone > carbonatite zone > clastic zone, which was mainly affected by Daji Mountain uranium polymetallic mining area in the northwest of Qishe Town. (3) The results of pollution index and ecological risk evaluations revealed Cd and As were the primary pollutants, which had a high contribution to the ecological risk of the three geological background zones. Overall, the degree of heavy metal pollution and potential ecological risk exhibited a pattern of carbonatite zone > carbonatite interbedded with clastic rock zone > clastic zone. Spatially, the areas with serious heavy metal pollution and strong risk were mainly distributed in the carbonatite zone in the south of Zhuchangping Town.