Potentially toxic element (PTE) pollution in farmland soil is a global problem. It is vital to clarify the contributions of farmland soil PTE from different sources to potential ecological risk (PER) and human health risks (HHR), but the existing research methods were incomplete. This study explored a comprehensive scheme that combined source contribution and risk assessment to quantitatively assess PER, HHR and the priority pollution sources. enrichment factor (EF) and pollution load index (PLI) were utilized to estimate the features of enrichment and contamination of PTE in farmland soil. Furthermore, spatial distribution characteristics of PTE and positive matrix factorization (PMF) were combined to distinguish and ascertain the sources of PTE, and the PER and HHR model based on PMF were applied to evaluate the ecological and human health risks in different sources. Taking Puning District as an example, four sources of farmland soil PTE were quantitatively allocated. For ecological risk, the study area was at moderate ecological hazard, with industrial activities (53.67%) contributing the most. The mean of Hg was 69.82, reaching medium ecological risk. For human health risks, both adults and children had no non-carcinogenic risk in the study area, and the natural source was the greatest contributor, followed by agricultural activities. The total carcinogenic risk index (TCRI) values for adults and children were 1.40E-05 and 2.75E-05, respectively, showing no significant carcinogenic risk. Furthermore, compared with adults, the health risks of children, whether noncarcinogenic or carcinogenic, were higher than those of adults.