Air is about 78% nitrogen. Nitrogen chemicals are needed for life. Nitrogen is a necessary part of proteins, DNA, and RNA. In plants, nitrogen is needed for photosynthesis and growth.  However, living things cannot use the elemental nitrogen in the air for these things. Nitrogen fixation is needed to change the nitrogen in air (N2) into forms that can be used by life. Most nitrogen fixation is done by microorganisms called bacteria. These bacteria have an enzyme that combines N2 with hydrogen gas (H2) to make ammonia (NH3).
Some of these bacteria live in the roots of plants (mostly legumes). In these roots, they make ammonia for the plant and the plant gives them carbohydrates. Other plants take nitrogen compounds out of the soil through their roots. All nitrogen in animals comes from eating plants.
Ammonium (NH4) in soil is made by nitrogen-fixing bacteria and decomposers, bacteria and fungi that break down dead life into its parts. This process is called ammonification. Ammonium has a positive charge. It easily joins to clay and humus in the soil. Ammonia and ammonium are poisonous to fish and other animals. Sewage and other waste-water is regularly measured because of this. If ammonia levels are too high, nitrification must happen.
Nitrification is the oxidation of ammonia and ammonium to nitrite (NO2−) and then to nitrate ( NO3−) by bacteria. Because nitrite and nitrate have a negative charge they do not easily join to soil and will wash out of the soil during rain and irrigation. High nitrate levels in drinking water is harmful for babies and can cause blue-baby syndrome.  High nitrate levels can also cause too much algae growth in lakes and pools. This eutrophication can be harmful to fish and other water animals. The use of fertilizers is controlled because of this.
Where there is no oxygen, some bacteria will make nitrate into nitrogen gas (N2) to extract energy. This starts the nitrogen cycle over again. This process is called denitrification.