“Magnesium (Mg) is needed for more than 300 biochemical reactions in the body. It helps maintain normal muscle and nerve function, keeps heart rhythm steady, supports a healthy immune system, and keeps bones strong. Magnesium also helps regulate blood sugar levels, promotes normal blood pressure, and is known to be involved in energy metabolism and protein synthesis. There is an increased interest in the role of magnesium in preventing and managing disorders such as hypertension, cardiovascular disease, and diabetes.” 
Where do WE get magnesium? Foods such as green leafy vegetables, some legumes, nuts, seeds and unrefined grains are good sources.  However, if those plants do not get enough magnesium, neither do we. Without enough magnesium, plants often develop some yellowing in their older leaves between the veins. Magnesium is essential for photosynthesis, and helps activate plant enzymes needed for growth. Animals have a need for more magnesium than plants, so a plant magnesium deficiency often shows up first in the animals, especially those that graze or forage.
|Montmorillonite clay soil||Serpentine||Vermiculite|
Where does magnesium come from? Magnesium is an abundant alkaline element in the earth’s crust, occurring naturally in several minerals like dolomite, vermiculite and clay soils like montmorillonite. It is the third most dissolved element in sea water, and seafoods are among the foods highest in magnesium. Alkaline soils and humus-rich soils generally contain more magnesium that acidic soils. Magnesium found in the form of magnesium ions (Mg2+) in the soil (in solution or bound to soil particles) is the most important for exchangeable magnesium. However, magnesium ions are at risk of leaching along with nitrates and calcium.
Other plant sources for magnesium are organic materials (compost), animal dung and plant material. The more magnesium taken up by the old plant material, the more will be available again for new crops. Cation Exchange Capacity, called CEC, (see http://www.spectrumanalytic.com/support/library/ff/CEC_BpH_and_percent_sat.htm) affects the potential for plants to take up magnesium. Soils with a high CEC tend to hold more magnesium. However, if there are also high levels of N and K (nitrogen and potassium) in the soil, less Mg will be available. You can add magnesium with serpentine superphosphate (a slow-release magnesium), dolomite (a calcium-magnesium limestone), and calcinated magnesite.
You can also add magnesium by using Epsom salts, which is very water-soluble (thus readily available to plants) and best used as a foliar spray to prevent leaching. Epsom salts is a magnesium sulfate, extracted from the mineral Epsomate, and naturally occurs in water. The name Epsom comes from the town in England (Epsom) where water was first boiled to release these minerals. The advantage of magnesium sulfate over other magnesium soil amendments (such as dolomitic lime) is its high solubility. 
Some plants, notably roses, tomatoes, potatoes and peppers require a soil high in magnesium. If you grow these, you should have a soil test done to determine magnesium levels, especially available magnesium, and then choose your magnesium amendment(s) carefully for optimal uptake.
Feed your plants with the right nutrition and they will feed you!
The magnesium crystals photo and the Dolomite photo are under GNU Free Documentation License, Version 1.2.
Anhydrous Magnesium sulfate, Serpentine and Vermiculite photos are in the public domain.