Background: Ammonium (NH4+) and nitrate (NO3−) are two major inorganic nitrogen (N) forms available for plant growth. Soil microbes affect the availability and transformation of these N forms in the rhizosphere, and this affects the N-use efficiency of plants. However, little is known about the responses of the rhizosphere bacterial community structure to NH4+ and NO3−. Here, a rhizobox containing a root zone (root growing area) and various soil compartments (0–0.5 cm, 0.5–1 cm, 1–2 cm, 2–4 cm, and 4–9 cm from the root zone) was designed to investigate the spatial distribution of bacterial diversity, community structure, and co-occurrence patterns along a distance from maize (Zea mays L.) roots with the addition of 15N-labeled NH4+ or NO3− in an acidic red soil.Results: Addition of NH4+ and NO3− reduced soil bacterial diversity in the maize root zone. The structures of soil bacterial communities differed between NH4+ and NO3− in the root zone and 0.5 cm away from the root zone. Soil pH was the major driver of bacterial community assembly during plant uptake of N. Maize roots recruited potentially beneficial acidophilic bacteria (e.g. Acidibacter, Burkholderia, and Catenulispora) under NH4+ treatment, and recruited growth-promoting bacteria that prefer higher pH (e.g. Sphingomonas, Sphingobium, Azospirillum, and Novosphingobium) under NO3− treatment. In the N-fertilization treatments, the soil bacterial networks were more complex in the root zone and its adjacent 0.5–1 cm zone than in other soil compartments. The soil bacterial networks were more complex under NH4+ treatment than under NO3−. More bacterial taxa in the networks responded positively and negatively to soil residual NH4+ than to NO3− in all zones in the rhizobox.Conclusions: The combined effects of the N form and the rhizosphere influenced the spatial patterns and co-occurrence network of soil bacterial communities at different distances from the maize root zone, mainly because of changes in soil pH during the uptake of NH4+ and NO3− by maize roots. Regulating microbial communities by adjusting soil pH through NH4+ and NO3− supply may be an environmentally friendly option for promoting soil microbial functions in intensively managed agro-ecosystems.