The fuel cell converts chemical energy into electricity, heat and water.

The principle is based on a simple chemical reaction:

Hydrogen + Oxygen → Electricity + Water + Heat

In the cell, a redox reaction is formed that creates electricity and heat. At the anode, the hydrogen molecule, in contact with a catalyst, decomposes and releases electrons that will create the electric current. This is the oxidation.

On the other hand, at the cathode, the oxygen, in contact with the electrons released by the previous reaction reacts. This is the reduction.

Finally, the hydrogen protons, when they arrive at the cathode, recombine with the oxygen ions and form water.

More information here