The basic idea behind photovoltaic (or 'solar') cells is actually fairly simple. First, you have a chunk of a semiconductor material like silicon. When this is properly "doped" with impurities, a p-n junction is formed. When light (like the light from the sun) hits this junction, some of the light's energy gets trapped. When this happens, some of the material's electrons get knocked loose and move around freely.
The p-n junction produces an intrinsic electric field. In the presence of this field, the loose electrons will all tend to move in one direction. Metal contacts on the edges of the semiconductor catch the moving electrons and let them travel onto wires. This is the electricity that you get back.
For a more in-depth description of how this happens, check out HowStuffWorks.com
p.s. If you think about it, this description may sound mysterious. If the electrons move toward one contact because the electric field pushes them that way, that's another way of saying that they have lower electrical potential energy there. Why then would they flow through the circuit to the other contact, where their electrical potential energy is higher? The answer lies in another factor that affects the way things flow: the entropy, which involves how many states are available to these particles. Particles in high-density regions usually have reduced entropy.
A fuller description of the p-n photovoltaic cell also would include another ingredient, the 'holes' in the sea of electrons, which act like oppositely charged particles and which can combine with electrons to leave no movable charged particles.
A slightly fuller description can be found at http://en.wikipedia.org/wiki/Theory_of_solar_cells
(published on 10/22/2007)