The hydrogen fuel (H2) enters one side of the fuel cell, where it encounters a catalyst, for example platinum, which splits the hydrogen atoms into a proton (H+) and electron (e-). The proton then travels through a membrane (the proton exchange membrane) to the other side of the fuel cell. But the electron cannot permeate easily through the membrane. Instead, its travels through an electrical wire to get to the other side, and delivers its energy to a "load" along the way, such as a light bulb. When it gets the other side of the fuel cell, the electron is recombined with the proton and the electron and an oxygen molecule from the air to make water.
The membrane in a PEM cell is made from "nafion", a sulfinate polymer made by Dupont. This only lets protons through because there are sulfinate (SO4) molecules in the polymer, which contain oxygen. The oxygen atoms "hog" the electrons of the sulfinate molecules, making the oxygen atoms slightly negatively charged, such that the positively charged protons can weakly bind to them. This allows them to permeate the membrane, and jump from one sulfinate molecule to another across the membrane, with help from thermal fluctuations and the electric field created across the membrane by the electron flow.
The platinum catalysts are also interesting. They may consist of very tiny (about 80 nanometer - several hundred atoms across) pieces of platinum, which are embedded on tiny butter larger (1 micrometer) pieces of carbon (pieces of "carbon black" to be specific), which themselves are attached to a carbon "cloth". The carbon is electrically neutral but conductive, and also porous, allowing the flow of gas and ions through it.