Herbivores obtain nitrogen through nitrate-containing proteins in the plants they eat. Neither plants nor animals can take in atmospheric nitrogen; instead, they rely on bacteria to convert nitrogen into a form plants can absorb.
In the nitrogen cycle, bacteria convert ammonia into nitrates. This process is called nitrogen fixation, and it allows plants to absorb the nitrogen they need for life. The bacteria that fix nitrogen are symbiotes that live on and around plant roots; they can absorb nutrients from the plants when needed, and the plants receive usable nitrates.
Plants use the nitrates to build proteins. Herbivores obtain the nitrogen they need by eating these plants; carnivores obtain their nitrogen by eating the herbivores. When an animal dies, ammonia is formed as a part of the natural decomposition process. Nitrogen-fixing bacteria break this ammonia down into nitrates, beginning the cycle again.
Atmospheric nitrogen can be introduced to the nitrogen cycle in two ways. The first is via some species of nitrogen-fixing bacteria; these microbes have the capability to convert atmospheric nitrogen directly to nitrates. The second is when nitrogen compounds are deposited in the soil through rainfall. During electrical storms, lightning can induce a chemical reaction between nitrogen and water. This reaction produces nitrates, which are deposited in the soil along with the rainwater.