Joseph Black did not discover the existence of magnesium, but he discovered through his experiments that magnesium is its own compound. His early experiments included mixing magnesium salt with acids.
Joseph Black was a student at the University of Edinburg in 1755 when he wrote his findings on magnesium in his thesis, “Experiments upon Magnesia Alba, Quicklime, and Some Other Alcaline Substances.” After Black discovered that magnesium gave off its own gas-lie calcium carbonate when mixed with acid, he heated the acid and magnesium mixture and saw that the magnesium did not bubble and dissolve into the acid. He then mixed it into water and saw that magnesium was not soluble in it.
He weighed the magnesium, and when it weighed less, he hypothesized that it was due to the gas it gave off when mixed with acid. To verify this, he added potassium carbonate in the amount the magnesium was missing, and the substance weighed the same again. This led him concluding that magnesium was its own compound.
Black took his studies further in 1756 when he studied calcium instead of magnesium. While Black was the first to recognize magnesium as its own compound, Sir Humphry Davy was the first to isolate it in 1808.