Nitrogen fixation is crucial for maintaining biological productivity in the oceans, because it replaces the biologically available nitrogen that is lost through denitrification. But, owing to its temporal and spatial variability, the global distribution of marine nitrogen fixation is difficult to determine from direct shipboard measurements. This uncertainty limits our understanding of the factors that influence nitrogen fixation, which may include iron, nitrogen-to-phosphorus ratios, and physical conditions such as temperature. Here we determine nitrogen fixation rates in the world's oceans through their impact on nitrate and phosphate concentrations in surface waters, using an ocean circulation model. Our results indicate that nitrogen fixation rates are highest in the Pacific Ocean, where water column denitrification rates are high but the rate of atmospheric iron deposition is low. We conclude that oceanic nitrogen fixation is closely tied to the generation of nitrogen-deficient waters in denitrification zones, supporting the view that nitrogen fixation stabilizes the oceanic inventory of fixed nitrogen over time.