To understand the soil toxic and hazardous elements content, pollution level, and ecological risk status in the northern margin of the Tibetan Plateau, we collected and analyzed 8273 sets of surface soil samples. Evaluations were conducted using the single-factor pollution index, geo-accumulation, pollution load, and potential ecological risk indices, and source identification correlation and principal component analysis. The results revealed that, compared with the background levels in China, the accumulation of soil arsenic, cadmium, nickel, and chromium was greater in the surface soil of the study area. Additionally, in comparison with Qinghai Province, more mercury accumulated in the surface soil of the study area and owing to the influence of anthropogenic activities. Benchmarking against soil environmental quality standards, the study area exhibited pollution control zones primarily dominated by arsenic and cadmium (3.9%). The spatial distribution revealed distinct zones: a ridge mountain type characterized by arsenic-cadmium-chromium-nickel, a Daban mountain type with solely cadmium presence, and a Longyangxia-Jianzha South type dominated by arsenic. Compared with the Qinghai Province soil background values, evaluations using the Pollution loading index, Geological Cumulative Index, and Potential Ecological Risk Index methods revealed varying degrees of potentially toxic element content exceedance. From an ecological risk perspective, the individual element with the highest potential ecological risk coefficients were mercury, followed by cadmium and arsenic; however, the region's overall ecological risk index was classified as low. Three distinct sources were identified: natural sources leading to high background levels of chromium, nickel, copper, zinc, and mercury; mixed natural and industrial/agricultural sources contributing to elevated cadmium levels; and human activity-related mercury enrichment. Based on the evaluation results, synergistic monitoring of soil and biota in naturally occurring risk zones is recommended to ensure the safety of agricultural and pastoral products. Additionally, ecological impact assessments and pollution source mitigation studies should be conducted in regions influenced by human activities to curb the further degradation of soil ecological quality.