Nitrogen fixation is any process which converts gaseous nitrogen into nitrogen-containing compounds.

In nature, nitrogen is most commonly fixed by certain types of soil-dwelling bacteria. The final, nitrogenous product of biological nitrogen fixation is ammonia.

Lightning also fixes nitrogen directly in the atmosphere, though at a much smaller total rate than that of bacteria. The extremely high temperatures momentarily brought about by a lightning flash are more than sufficient to break apart molecules of nitrogen and oxygen, allowing the nitrogen and oxygen atoms to react with one another and form nitrogen dioxide, which in turn produces nitric acid when it encounters water.

Under artificial conditions, nitrogen fixation is done on a large scale by the Haber-Bosch process.