Consider the example burning of magnesium ribbon (Mg). When magnesium burns, it combines with oxygen () from the air to form magnesium oxide (MgO) according to the following equation:
Magnesium oxide is an ionic compound containing  and  ions whereas  and  are elements with no charges. 
The  with zero charge gains a +2 charge going from the reactant side to product side, and the   with zero charge gains a –2 charge. This is because when  becomes , it loses 2 electrons. Since there are 2 Mg on left side, a total of 4 electrons are lost according to the following oxidation half reaction:
On the other hand,  was reduced: its oxidation state goes from 0 to -2. Thus, a reduction half reaction can be written for the O2 as it gains 4 electrons:
The overall reaction is the sum of both half reactions:
When chemical reaction, especially, redox reaction takes place, we do not see the electrons as they appear and disappear during the course of the reaction. What we see is the reactants (starting material) and end products. Due to this, electrons appearing on both sides of the equation are canceled. After canceling, the equation is re-written as
Two ions, positive () and negative () exist on product side and they combine immediately to form a compound magnesium oxide (MgO) due to their opposite charges (electrostatic attraction). In any given oxidation-reduction reaction, there are two half reactions—oxidation half reaction and reduction half reaction. The sum of these two half reactions is the oxidation–reduction reaction.