Clarifying the effects of oil sunflower cultivation on soil environment and microbial community structure and function in historically heavy metal-contaminated fields can provide a scientific basis for green remediation of soil functionality. Using high-throughput sequencing of soil microbe and metagenomic analysis, we examined the differences in soil microbial community structure, gene functions, and environmental factors (soil heavy metals and physicochemical indicators) in long-term contaminated land by heavy metals from smelters under three oil sunflower planting conditions \[uncultivated wasteland (U_S), stunted-growth (SF_S) and vigorous-growth (SF_L)\], and explored the causes of such differences. Results showed that under the background of high Cd, Cu, Pb and Zn, oil sunflower planting significantly improved soil enzyme activities of urease, invertase, peroxidase and phosphatase, and soil microbial community structure significantly changed. Bacteria
Pseudomonas,
norank_f__Gemmatimonadaceae,
norank_f__norank_o__Gaiellales,
norank_f__norank_o__C0119,
norank_f__SC-I-84,
norank_f__norank_o__Acidobacteriales and fungi
Fusarium,
Penicillium,
Solicoccozyma,
unclassified_Fungi,
unclassified_f__Archaeosporaceae dominated in U_S soil, while bacteria
Microvirga,
Pseudoxanthomonas and fungi
unclassified_f__Pyronemataceae,
unclassified_f__Sordariaceae were dominant genera in SF_L soil. The abundance ratios of dominant bacterial and fungal genera were negatively correlated with Pb, Cd, and TP, but positively correlated with pH, catalase, and urease. Meanwhile, metagenomics analysis showed that the gene functions of the main bacterial and fungal genera in the soil were dominated by transport and detoxification effects under the background of high heavy metal pollution. The Mantel-test network analysis of metagenomics and environmental factors revealed that oil sunflower cultivation elevated overall functional activity of soil microbes and improved soil quality under high heavy metal stress.