The nitrogen cycle works by driving the circulation of nitrogen through biotic and abiotic components of an ecosystem. The cycle begins and ends with molecular nitrogen floating freely as a major component of the Earth's atmosphere.
Atmospheric nitrogen can be taken up by rain and carried to the soil as nitric acid, or HNO3. Once in the soil, bacteria and some legume-type plants fix the nitrogen. Peanuts, clover and soy exist symbiotically with microbes to use nitric acid as a fertilizer to aid their growth. A byproduct of this process is a chemical called ammonia, or NH3. Ammonia is used as a fuel by specialist bacteria that ultimately convert it into nitrate, NO3-, which the plants can then use to efficiently synthesize proteins.
When plants die, their nutrients are consumed by microorganisms in the soil. The nitrate they used in life is then available to these microbes for further decomposition. As it is consumed, nitrate is cracked by the microbes' metabolic processes into nitrogen gas, N2, and a secondary byproduct known as nitrous oxide, or NO2. The molecular nitrogen, thus liberated from the biotic component of the cycle, is excreted by the microbes and wafts back up into the atmosphere to await the next rain.