Overuse of chemical fertilizers (CF) degrades soil and environmental quality.Replacing chemical fertilizer (CF) with biogas slurry (BS), an organic alternative, offers a sustainable solution. However, the mechanisms by which BS balances yield benefits with N2O emissions, along with metagenomic insights, remain unclear. This study examined six fertigation strategies including control,100 %CF, and 25 %, 50 %, 75 %, and 100 % BS substitution for CF, on soil quality index (SQI), nitrogen use efficiency (NUE), wheat growth and nutrient uptake, grain yield, and N2O emissions, along with metagenomic analysis. The results showed that 50 % BS substitution significantly (p < 0.001) increased wheat tillers (43.5 %), dry matter (21.6 %), N uptake (52.6 %), NUE (32.2 %), and grain yield (24.4 %) compared to 100 %CF. Furthermore, it also reduced N2O emissions by 26.9 % and yield-scaled N2O emissions by 44.8 %. The structural equation modeling (SEM) demonstrated that the enhanced SQI (57.8 %) significantly boosted grain yield and NUE, which was ascribed to the N2O emission reduction. The 50 %BS treatment significantly reduced archaeal ammonia monooxygenase (Arch-amoA) abundance compared to 100 %CF, with metagenomic analysis revealing that N2O emissions were mainly attributed to Arch-amoA. SEM analysis confirmed that N2O emissions were mainly driven by Arch-amoA over the bacterial ammonia monooxygenase (Bac-amoA) in nitrification and nosZ over nirS in denitrification, significantly reducing emissions. Random Forest analysis identified that available N (NH4+-N and NO3--N) dominantly moderated grain yield, while soil pH, C:N, available N, and total N importantly regulated N2O emissions. Replacing 50 % CF with BS in wheat sustainably enhances yield, reduces N2O emissions, and promotes environmental sustainability.