Nitrogen is a gas, the main component of the atmosphere. It was recognized as a distinct element in 1772 during that 18th Century of discovery when the science of chemistry was being developed. Nitrogen is necessary to plants, as it is used to build proteins, DNA, and most of the molecules of life.
Although nitrogen makes up 78% of the atmosphere, most plants cannot use it in this form. The two atoms in the nitrogen molecule (N2) are held together by a strong triple bond. Lightning can break this bond and combine the nitrogen into a more usable form such as nitrous oxide. Most nitrogen, though, is removed from the atmosphere ("fixed") by bacteria, either free bacteria in the soil or symbiotic bacteria in plants. Legumes (alfalfa, peas, beans) consume nitrogen gas because of symbiotic bacteria living in their root nodules.
In the world of agriculture, nitrogen is added to fertilizer in the form of ammonia (NH3), and that is a form that plants can absorb.
Neither nitrogen nor ammonia is mined directly, but the simple chemical ammonia is made from natural gas, methane. It can also be made from reacting coal (carbon) with steam and from other processes. Ammonia is a favorite input for the chemical industry, which is thus dependent on the mining of fossil fuels.
There is one case in which ammonia is mined directly. Ammonia (along with nitrates and phosphates) is found in guano, the droppings of birds and bats. Particularly in South America, guano is mined and used as fertilizer.