The application of organic fertilizers has become an increasingly popular substitution in maize production to reduce gaseous nitrogen (N) loss and soil degradation caused by inorganic fertilizers. Organic fertilizer plays a key role in improving soil quality and stabilizing maize yields, but studies that refine different substitution rates remain poorly documented. A field study was carried out in 2021 and 2022 based on a long-term trial initiated in 2016. The experiment included five organic fertilizer N substitution rates with equal input of 200 kg N ha–1: 0% organic fertilizer (T1, 100% inorganic fertilizer), 50.0% organic+50.0% inorganic fertilizer (T2), 37.5% organic+62.5% inorganic fertilizer (T3), 25.0% organic+75.0% inorganic fertilizer (T4), 12.5% organic+87.5% inorganic fertilizer (T5), and no fertilizer control (T6). The average result of two years showed that T3 and T1 had the highest grain yield and biomass, respectively, and there was no significant difference between T1 and T3. Compared with T1, 12.5, 25.0, 37.5, and 50.0% substitution rates (T5, T4, T3, and T2) significantly reduced total nitrogen loss (NH3、N2O) by 8.3, 16.1, 18.7, and 27.0%, respectively. Nitrogen use efficiency (NUE) was higher in T5, T3, and T1, and there was no significant difference among them. The organic fertilizer substitution directly reduced NH3 volatilization and N2O emission from farmland by lowering ammonium nitrogen and alkali-dissolved N content and by increasing soil moisture. These substitution treatments reduced N2O emissions indirectly by regulating the abundance of AOB and nirK-harboring genes by promoting soil moisture. The 37.5% of organic fertilizer substitution reduces NH3 volatilization and N2O emission from farmland by decreasing ammonium nitrogen and alkali-dissolved N content and increasing moisture which negatively regulate the abundance of AOB and nirK-harboring genes to reduce N2O emissions indirectly in rainfed maize fields on the Loess Plateau of China.