In most terrestrial ecosystems, plant growth is limited by nitrogen and phosphorus. Adding either nutrient to soil usually affects primary production, but their effects can be positive or negative. Here we provide a general stoichiometric framework for interpreting these contrasting effects. First, we identify nitrogen and phosphorus limitations on plants and soil microorganisms using their respective nitrogen to phosphorus critical ratios. Second, we use these ratios to show how soil microorganisms mediate the response of primary production to limiting and non-limiting nutrient addition along a wide gradient of soil nutrient availability. Using a meta-analysis of 51 factorial nitrogen–phosphorus fertilization experiments conducted across multiple ecosystems, we demonstrate that the response of primary production to nitrogen and phosphorus additions is accurately predicted by our stoichiometric framework. The only pattern that could not be predicted by our original framework suggests that nitrogen has not only a structural function in growing organisms, but also a key role in promoting plant and microbial nutrient acquisition. We conclude that this stoichiometric framework offers the most parsimonious way to interpret contrasting and, until now, unresolved responses of primary production to nutrient addition in terrestrial ecosystems.