A fuel cell is a device that converts chemical potential energy (energy stored in molecular bonds) into electrical energy. A PEM (Proton Exchange Membrane) cell uses hydrogen gas (H2) and oxygen gas (O2) as fuel. The products of the reaction in the cell are water, electricity, and heat. This is a big improvement over internal combustion engines, coal burning power plants, and nuclear power plants, all of which produce harmful by-products.
Since O2 is readily available in the atmosphere, we only need to supply the fuel cell with H2which can come from an electrolysis process (see Alkaline electrolysis or PEM electrolysis).
Hydrogen + Oxygen = Electricity + Water Vapor
Cathode: O2 + 4H+ + 4e- → 2H2O
Anode: 2H2 → 4H+ + 4e-
Overall: 2H2 + O2 → 2H2O