Approximately 50% of the global natural fixation of nitrogen occurs in the oceans supporting a considerable part of the new primary production. Virtually all nitrogen fixation in the ocean occurs in the tropics and subtropics where the surface water temperature is 25°C or higher. It is attributed almost exclusively to cyanobacteria. This is remarkable firstly because diazotrophic cyanobacteria are found in other environments irrespective of temperature and secondly because primary production in temperate and cold oceans is generally limited by nitrogen. Cyanobacteria are oxygenic phototrophic organisms that evolved a variety of strategies protecting nitrogenase from oxygen inactivation. Free-living diazotrophic cyanobacteria in the ocean are of the non-heterocystous type, namely the filamentous Trichodesmium and the unicellular groups A-C. I will argue that warm water is a prerequisite for these diazotrophic organisms because of the low-oxygen solubility and high rates of respiration allowing the organism to maintain anoxic conditions in the nitrogen-fixing cell. Heterocystous cyanobacteria are abundant in freshwater and brackish environments in all climatic zones. The heterocyst cell envelope is a tuneable gas diffusion barrier that optimizes the influx of both oxygen and nitrogen, while maintaining anoxic conditions inside the cell. It is not known why heterocystous cyanobacteria are absent from the temperate and cold oceans and seas.