While there are a few different types of fuel cells, all share the same basic setup. Layers of materials with distinct electrochemical properties are sandwiched together to form a single galvanic cell. At the heart lies a membrane that can only be crossed by charged molecules. Gas-permeable electrodes coated with a catalyst adhere to this membrane, adding a layer on either side. These electrodes are in turn connected to a device that can utilize electricity — a load — which creates a complete electrical circuit.
The following description details the internal workings of a Proton Exchange Membrane (PEM) fuel cell, favored for widespread use because of its low-temperature operation, relative tolerance for impurities, and high power-density. According to U.S. Department of Energy, "these cells are the best candidates for light-duty vehicles, for buildings, and much smaller applications."
To learn more about other configurations, see Types of Fuel Cells.

(image courtesy of Ballard Power Systems, www.ballard.com)
Hydrogen gas (H
2) flows into channels on one face of the cell and migrates through that electrode, while the same occurs with oxygen gas (O
2, typically from the ambient air) along the opposite electrode. Spurred by a catalyst, favorable chemistry causes the hydrogen to oxidize into hydrogen protons and give up its electrons to the neighboring electrode, which thereby becomes the anode. This buildup of negative charge then follows the path of least resistance via the external circuit to the other electrode (the cathode). It is this
flow of electrons through a circuit that creates electricity.
But this wouldn't continue for long without a complete electrochemical cycle. As the electrical current begins to flow, hydrogen protons pass through the membrane from the anode to the cathode. When the electrons return from doing work lighting your house, charging a battery, or powering your car's motor, for example they react with oxygen and the hydrogen protons at the cathode to form water. Heat emanates from this union (an exothermic reaction), as well as from the frictional resistance of ion transfer through the membrane. This thermal energy can be utilized outside the fuel cell. To summarize:
Anode Reaction: H2 > 2 H+
+ 2 e-
Cathode Reaction: ½ O2 + 2 H+ + 2 e- > H2O
An individual fuel cell produces DC electricity at a low-voltage. To meet common power needs, multiple fuel cells are arranged face-to-face in series to create a fuel cell stack. This inherent modularity of fuel cells allows them to be manufactured in virtually any size.