The electron comes from the cation that the hydroxide ion is in the solution with. For example, you have a piece of sodium metal and you put it into a beaker with water, the sodium forms Na
+ so it loses an electron to the water molecule, so the oxygen now has nine electrons (well, sort of, maybe just for a sec
), so it 'kicks' out a hydrogen atom, and it has eight again, except now it is the hydroxide ion OH
-, this is where the electron came from. The reaction goes 2Na + 2H
2O
2NaOH + H
2. The two 'kicked' out hydrogen atoms combine to form hydrogen gas.