If we join the N and P materials together (create a diode) the electrons in the N material diffuse (move or spread out) across the junction into the P material and fill some of the holes. At the same time, the holes in the P material diffuse across the junction into the N material and are filled by N material electrons. This process, called JUNCTION RECOMBINATION, reduces the number of free electrons and holes in the vicinity of the junction. Because there is a depletion, or lack of free electrons and holes in this area, it is known as the DEPLETION REGION.
The loss of an electron from the N-type material created a positive ion in the N material, while the loss of a hole from the P material created a negative ion in that material. These ions are fixed in place in the crystal lattice structure and cannot move. Thus, they make up a layer of fixed charges on the two sides of the junction.
On the N side of the junction, there is a layer of positively charged ions; on the P side of the junction, there is a layer of negatively charged ions. An electrostatic field is established across the junction between the oppositely charged ions. The diffusion of electrons from the P-type material towards the positively charged N-type material and holes from N-type towards the negatively charged P-type is favored.
In between the p and n side, the built-in voltage is created and because of this reasons, there is also the drift current besides with the diffusion current.