The impact of nitrogen (N) and phosphorus (P) fertilizer inputs on soil nutrient cycling and ecological function processes has garnered significant attention. Soil multifunctionality primarily refers to the soil's ability to perform multiple functions simultaneously, particularly the functions related to the genes involved in carbon (C), nitrogen (N), and phosphorus (P) cycles, which are critical for ecosystem sustainability. Despite this, the effects of N and P fertilizers on the expression of genes involved in soil carbon (C), nitrogen (N), and phosphorus (P) cycles, and their consequent influence on soil multifunctionality, remain unclear. To investigate this, we conducted a long-term nine-year experiment. The experimental site was fenced to prevent grazing and included four treatments: Control (no fertilizer), N (10 g N m−2 y−1, urea), P (5 g P m−2 y−1, Ca(H2PO4)2), and NP (10 g N and 5 g P m−2 y−1, urea and Ca(H2PO4)2). We examined the effects of these treatments on soil microbial functional gene abundance and multifunctionality. Our findings revealed that N addition altered the composition of soil microbial functional genes but did not affect functional diversity. Both N and P inputs, as well as their combination, negatively impacted soil carbon fixation and the genes encoding enzymes for the degradation of starch, hemicellulose, cellulose, and chitin. N input also disrupted soil nitrogen and phosphorus cycling by inhibiting the expression of soil denitrification genes (nirS and nosZ), phytate hydrolase gene (cphy), and a phosphatase gene (phoD). Additionally, P input significantly inhibited functional genes involved in soil nitrification, denitrification, ammonification, nitrogen fixation, and ammonia oxidation processes. It also adversely affected phytate synthesis and degradation. The combined N and P inputs had a substantial negative impact on soil nitrification (hao), denitrification (narG, nirK, nirS, and norZ), ammonification (gdh), nitrogen fixation, annamox, and nitrogen reduction, and inhibited the expression of soil phosphorus cycle genes. Long-term phosphorus application was found to have a more detrimental effect on soil multifunctionality compared to nitrogen application. Furthermore, our study showed that vegetation diversity and abundance are crucial drivers of soil carbon, nitrogen, and phosphorus cycling functional genes and multifunctionality. We concluded that N and P inputs alter soil multifunctionality by influencing vegetation diversity; therefore, maintaining vegetation diversity is essential for sustaining soil multifunctionality.