Uncertainty in the global patterns of marine nitrogen fixation limits our understanding of the response of the ocean's nitrogen and carbon cycles to environmental change. The geographical distribution of and ecological controls on nitrogen fixation are difficult to constrain with limited in situ measurements. Here we present convergent estimates of nitrogen fixation from an inverse biogeochemical and a prognostic ocean model. Our results demonstrate strong spatial variability in the nitrogen-to-phosphorus ratio of exported organic matter that greatly increases the global nitrogen-fixation rate (because phytoplankton manage with less phosphorus when it is in short supply). We find that the input of newly fixed nitrogen from microbial fixation and external inputs (atmospheric deposition and river fluxes) accounts for up to 50 per cent of carbon export in subtropical gyres. We also find that nitrogen fixation and denitrification are spatially decoupled but that nevertheless nitrogen sources and sinks appear to be balanced over the past few decades. Moreover, we propose a role for top-down zooplankton grazing control in shaping the global patterns of nitrogen fixation. Our findings suggest that biological carbon export in the ocean is higher than expected and that stabilizing nitrogen-cycle feedbacks are weaker than previously thought.