Global climate models have not yet considered the effects of nutrient cycles and limitation when forecasting carbon uptake by the terrestrial biosphere into the future. Using the principle of resource optimization, we here develop a new theory by which C, N, and P cycles interact. Our model is able to replicate the observed responses of net primary production to nutrient additions in N-limited, N- and P-colimited, and P-limited terrestrial environments. Our framework identifies a new pathway by which N2 fixers can alter P availability: By investing in N-rich, phosphorus liberation enzymes (phosphatases), fixers can greatly accelerate soil P availability and P cycling rates. This interaction is critical for the successful invasion and establishment of N2 fixers in an N-limited environment. We conclude that our model can be used to examine nutrient limitation broadly, and thus offers promise for coupling the biogeochemical system of C, N, and P to broader climate-system models.