Atmospheric nitrogen is notoriously unreactive having a very strong triple bond between the two atoms in the molecule yet it is vital for all living organisms.
The bacteria and probably the archaea are the only organisms that can ‘fix’ nitrogen from the atmosphere. Some of these bacteria are always free living like the Azotobactor. However, it is suggested that free living nitrogen fixing bacteria do not contribute significant amounts of nitrogen to the soil.
Rhizobia are free living heterotrophic bacteria that can form symbiotic relationships with leguminous plants. There are many different species of Rhizobium; some which can form symbiotic relationships with many plants and some which are specific to certain plants. They are nitrogen fixers but only when in a symbiotic relationship with a leguminous plant.
Some non leguminous plants can form symbiotic relationships with other genera of nitrogen fixing bacteria; such as alder with Frankia alni.
Rhizobia are able to fix nitrogen from the air using the enzyme nitrogenase.
These bacteria are able to produce ammonia from atmospheric nitrogen and plants can use this to make amino acids and eventually proteins. Nitrogen fixed by bacteria can also be used to make plant nucleotides.
Nitrogen is used to make amino acids that are the building blocks of proteins. The majority of cell components in bacteria, fungi, plants and animals are made from proteins. Contrary to the common misconception, lettuce does contain protein.
As the nitrogen fixed in this way is essential to the plant and bacteria and has been gained through the expenditure of lots of energy, none is lost to the rhizosphere. However, nitrogen is lost as proteins when cells are sheared off during root elongation and possibly by protein rich root exudates. There is a great turnover of roots and when they die they add nitrogen to the soil in the form of proteins and nucleotides.
However, the greatest amount of nitrogen is added to the soil when the plant dies. The proteins and nucleotides in leaves, stem and roots are decomposed by bacteria in the soil releasing the nitrogen originally fixed by rhizobia. This nitrogen enters the soil and is available for other plants to take up. A proportion of the Rhizobia in the root nodule escape back into the soil when the host plant dies but they will not be able to fix nitrogen when living in the soil.
So, this is why you need to dig in the tops as well as the roots of your peas and beans. Do not burn the tops or you will loose all your hard earned nitrogen in the form of nitrogen oxide gases.