At the core of the idea of hydrogen engines is the PEM (Proton Exchange Membrane, also called the Polymer Electrolyte Membrane).

It uses a simple chemical process to combine hydrogen and oxygen into water, producing electric current in the process. This process is essentially the inverse of electrolysis. A PEM is permeable to protons but not electrons. This is crucial to the generation of current in hydrogen fuelcells. This process goes as follows :

At the anode(usually platinum), the hydrogen molecules release their electrons when they become hydrogen ions in order to pass through the membrane, leaving the electrons behind, creating a potential difference between the two sides of the membrane.

The electrons are now attracted to the cathode where the hydrogen ions/protons are oxidising, and are forced to go through an external circuit, thereby produce electriccurrent. This current can perform useful work by powering electric devices. The enerby provided stems from the energy added to the system during the initial electrolysis of water that would have produced the uncombined hydrogen and oxygen molecules.

As the electrons reach the oxygen, and hydrogen ions, they combine to create an amount of water equal to that which was electrolysed.

        H^2
             |
     ANODE Here, the H^2 molecule splits up.
      (4H+)  |---->----(4e-)------>-----\ 
| |
PROTON EXCHANGE MEMBRANE |
| |
| V
CATHODE (with O^2) |
| | |
(combination to form water---------/

The creation of the constituent hydrogen and oxygen that forms this pure water would probably use nuclear, fusion or solar energy. Since, due to the continual pollution of our freshwater and oceanic water reserves, pure water would be in constant demand, the water "byproduct" would have to be deposited at every (literally)gas station serving hydrogen-powered vehicles. For a comparison with a biological process, see: the proton gradient