IntroductionA growing amount of heavy metal contamination in soil disturbs the ecosystem’s equilibrium, in which microbial populations play a key role in the nutrient cycle of soils. However, given the different sensitivity of microbial communities to different spatial and temporal scales, microbial community structure and function also have varied response mechanisms to different heavy metal contaminated habitats.MethodsIn this study, samples were taken prior to Cr stress (CK) and 6 h and 6 days after Cr stress (Cr_6h, Cr_6d) in laboratory experiments. High-throughput sequencing revealed trends in the structure and diversity of the bacterial communities, and real-time fluorescence quantitative polymerase chain reaction (qPCR) was used to analyze trends in nitrogen cycle functional genes (AOA-amoA, AOB-amoA, narG, nirK, and nifH).ResultsThe findings showed that (1) the composition structure of the soil bacterial community changed considerably in Cr–stressed soils; α-diversity showed significant phase transition characteristic from stress to stability (p < 0.05). (2) With an overall rising tendency, the abundance of the nitrogen cycle functional genes (AOA-amoA and AOB-amoA) decreased considerably before increasing, and α-diversity dramatically declined (p < 0.05). (3) The redundancy analysis (RDA) and permutational multivariate analysis of variance (PERMANOVA) tests results showed that the soil physicochemical parameters were significantly correlated with the nitrogen cycle functional genes (r: 0.4195, p < 0.01). Mantel analysis showed that available nitrogen (N), available potassium (K), and available phosphorus (P) were significantly correlated with nifH (p = 0.006, 0.008, 0.004), and pH was highly significantly correlated with nifH (p = 0.026). The PLS-ME (partial least squares path model) model further demonstrated a significant direct effect of the soil physicochemical parameters on the nitrogen cycling functional genes.DiscussionAs a result, the composition and diversity of the bacterial community and the nitrogen cycle functional genes in Cr–stressed agricultural soils changed considerably. However, the influence of the soil physicochemical parameters on the functional genes involved in the nitrogen cycle was greater than that of the bacterial community. and Cr stress affects the N cycling process in soil mainly by affecting nitrification. This research has significant practical ramifications for understanding the mechanisms of microbial community homeostasis maintenance, nitrogen cycle response mechanisms, and soil remediation in heavy metal–contaminated agricultural soils.