The photovoltaic effect is a process that generates voltage or electric current in a photovoltaic cell when it is exposed to sunlight. It is this effect that makes solar panels useful, as it is how the cells within the panel convert sunlight to electrical energy. The photovoltaic effect was first discovered in 1839 by Edmond Becquerel. When doing experiments involving wet cells, he noted that the voltage of the cell increased when its silver plates were exposed to the sunlight.
The photovoltaic effect occurs in solar cells. These solar cells are composed of two different types of semiconductors - a p-type and an n-type - that are joined together to create a p-n junction. To read the background on what these semiconductors are and what the junction is, click here. By joining these two types of semiconductors, an electric field is formed in the region of the junction as electrons move to the positive p-side and holes move to the negative n-side. This field causes negatively charged particles to move in one direction and positively charged particles in the other direction.
Light is composed of photons, which are simply small bundles of electromagnetic radiation or energy. These photons can be absorbed by a photovoltaic cell - the type of cell that composes solar panels. When light of a suitable wavelength is incident on these cells, energy from the photon is transferred to an atom of the semiconducting material in the p-n junction. Specifically, the energy is transferred to the electrons in the material. This causes the electrons to jump to a higher energy state known as the conduction band. This leaves behind a "hole" in the valence band that the electron jumped up from. This movement of the electron as a result of added energy creates two charge carriers, an electron-hole pair.
When unexcited, electrons hold the semiconducting material together by forming bonds with surrounding atoms, and thus they cannot move. However in their excited state in the conduction band, these electrons are free to move through the material. Because of the electric field that exists as a result of the p-n junction, electrons and holes move in the opposite direction as expected. Instead of being attracted to the p-side, the freed electron tends to move to the n-side. This motion of the electron creates an electric current in the cell. Once the electron moves, there's a "hole" that is left. This hole can also move, but in the opposite direction to the p-side. It is this process which creates a current in the cell. A diagram of this process can be seen in Figure 1.