Nitrogen compounds in wasteproducts (urine and faeces) and deadorganism are converted into ammonia by saprobinots (a type of décomposer including some fungi and bacteria)
this ammonia forms ammonium ions in the soil
nitrification
The ammonium ions in the soil are oxidised to nitrites then nitrates by nitrifying bacteria.
denitrification
converts nitrogen in compounds back to nitrogen gas.