The spatial distribution and source analysis of heavy metals in soil are of great significance for the risk assessment and control of heavy metal pollution. Herein, a total of 87 topsoil samples (0–30 cm) were collected in the areas adjacent to a non-ferrous metal slag field of Gejiu City, Yunnan Province. The typical heavy metal concentrations, available phosphorus, available potassium, ammonium nitrogen, nitrate nitrogen, and pH in each soil sample were determined. Based on the above basic data, distribution and origins of heavy metals was analyzed. The results indicated that the mean contents of Pb, As, Cu, Zn, Ni and Cr in the topsoil of the study site were 247.82, 204.36, 104.83, 411.38, 29.73 and 67.59 mg kg-1, respectively. Exception of the Ni element, the contents of the remaining five heavy metals surpassed their respective background levels in study site. Especially, As element (with the highest accumulation effect) is 11.1l times of the background level, and the remaining four elements are 1.04–6.10 times of the background level in Yunnan. Single factor pollution index showed that the pollution degree of Pb, Cu and Zn was light, and the accumulation of As was a great threat to soil quality. Furthermore, the percentages of sites at mild pollution, moderate pollution and heavy pollution levels were 16.09%, 26.09% and 63.22%, respectively. Additionally, The order of potential ecological hazard degree of soil in the survey area was As > Pb > Cu = Ni > Zn = Cr. The spatial dispersion of heavy metals within the study region is impacted by both natural phenomena and human activities. The areas with severe pollution were the mining area in the northwest and planting sites in the east, middle and south of the study area. The main contribution sources of Ni were the mixed sources of natural parent material and industrial activities. The heavy metal element largely contributed by industrial activities and transportation is Pb. The main sources of metals As, Cu and Zn are the integrated sources of agricultural and industrial activities. The main source of Cr is natural source. Therefore, these useful results can guide the heavy metal pollution control and restoration of study site and this research work can also be used to other similar metal slag field and its affected area.