Nitrate leaching in croplands with excessive chemical fertilizer application is a serious issue for sustainable agriculture. Microbes are the primary drivers of nitrate transformation in the soil and are considered a potential solution for nitrogen leaching. However, practical approaches are lacking. In this study, the effects of the addition of biogas slurry on nitrogen leaching and soil microbial communities were investigated. Column incubation experiments showed that the addition of biogas slurry at a depth of 20 cm significantly decreased nitrate leaching by 30.97% and shaped a bacterial community rich in taxa involved in nitrate ammonification and denitrification. Using a mechanized application method, the field experiment showed that biogas slurry application significantly increased the abundance of nirK-, nirS-, nosZ-, and nrfA-harboring microbes and decreased the risk of nitrate leaching without reducing crop yield and the soil nitrogen pool. These results showed that the appropriate application of biogas slurry effectively mitigates nitrogen leaching by enhancing soil microbial nitrate transformation and confirmed the feasibility of solving environmental problems by regulating the microbial community and function.