A P-N junction is formed when a p-type semiconductor and an n-type semiconductor are placed in contact with each other. Current flows readily in one direction through this junction (this direction is referred to as forward biased), but will not flow easily in the opposite direction (which is reverse biased). The formation of a P-N junction creates a basic diode. For an explicit explanation of how these diodes work, click here.
The joining of these two types of semiconductors results in a movement of charge carriers. The n-type semiconductor has a higher concentration of negative charge carriers - electrons. Conversely, the p-type semiconductor has a higher concentration of the positive charge carrier - electron holes. As a result of the difference in concentrations, electrons move and diffuse from the n-type side to the p-type side. Holes diffuse in the opposite direction. In a p-n junction, the diffusion of holes and electrons across the junction results in exposed charges - positive or negative ion cores in the crystal lattice structure of the semiconductor. Figure 1 below shows the general structure of these junctions for reference.
As a result of the diffusion of these charge carriers and the exposing of these ions, an electric field is created at the junction. Since an electric field exists at this point, a voltage exists as a result of this field. The are between these negative and positive ions where the electric field is produced is known as the depletion region. It is called this because in this area, the electric field quickly moves charge carriers out. As a result of this, the depletion region contains no charge carriers as the negative and positive charges essentially cancel each other out.