Soil health is seriously threatened by the overuse of chemical fertilizers in agricultural management. Biogas slurry is often seen as an organic fertilizer resource that is rich in nutrients, and its use has the goal of lowering the amount of chemical fertilizers used while preserving crop yields and soil health. However, the application of continuous biogas slurry has not yet been studied for its long-term impact on soil nutrients and microbial communities in a rotation system of annual ryegrass-silage maize (Zea mays). This study aimed to investigate the impacts on the chemical properties and microbial community of farmland soils to which chemical fertilizer (NPK) (225 kg ha-1), biogas slurry (150 t ha-1), and a combination (49.5 t ha-1 biogas slurry + 150 kg ha-1 chemical fertilizer) were applied for five years. The results indicated that compared to the control group, the long-term application of biogas slurry significantly increased the SOC, TN, AP, and AK values by 45.93%, 39.52%, 174.73%, and 161.54%, respectively; it neutralized acidic soil and increased the soil pH. TN, SOC, pH, and AP are all important environmental factors that influence the structural composition of the soil's bacterial and fungal communities. Chemical fertilizer application significantly increased the diversity of the bacterial community. Variation was observed in the composition of soil bacterial and fungal communities among the different treatments. The structure and diversity of soil microbes are affected by different methods of fertilization; the application of biogas slurry not only increases the contents of soil nutrients but also regulates the soil's bacterial and fungal community structures. Therefore, biogas slurry can serve as a sustainable management measure and offers an alternative to the application of chemical fertilizers for sustainable intensification.