The most common magnesium ion has a +2 charge, which means it has lost two of its original 12 electrons, leaving it with a total of 10 electrons. The atomic number of magnesium is 12, which means that in its stable state, it has 12 protons and 12 electrons.
An ion forms when an atom either loses or gains electrons. If the atom gains electrons, it becomes a negatively charged ion. If it loses electrons, it becomes a positively charged ion. In the case of magnesium, the most common ion is Mg+2. This occurs when magnesium hydroxide, the main ingredient in Milk of Magnesia, forms. It is possible for magnesium to form bonds that create a different ion.