Microorganisms oxidize organic nitrogen to nitrate in a series of steps. Nitrite, an intermediate product, accumulates at the base of the sunlit layer in the subtropical ocean, forming a primary nitrite maximum, but can accumulate throughout the sunlit layer at higher latitudes. We model nitrifying chemoautotrophs in a marine ecosystem and demonstrate that microbial community interactions can explain the nitrite distributions. Our theoretical framework proposes that nitrite can accumulate to a higher concentration than ammonium because of differences in underlying redox chemistry and cell size between ammonia- and nitrite-oxidizing chemoautotrophs. Using ocean circulation models, we demonstrate that nitrifying microorganisms are excluded in the sunlit layer when phytoplankton are nitrogen-limited, but thrive at depth when phytoplankton become light-limited, resulting in nitrite accumulation there. However, nitrifying microorganisms may coexist in the sunlit layer when phytoplankton are iron- or light-limited (often in higher latitudes). These results improve understanding of the controls on nitrification, and provide a framework for representing chemoautotrophs and their biogeochemical effects in ocean models.