Whenever it rains or during thunderstorm, occurrence of lightning is a usual phenomenon. We do see flashes of light in the sky with cracking sound. To understand the reason behind lightning we need to look at the process of how the cloud is formed as for lightning to occur it is necessary to have clouds in the sky.
Earth’s atmosphere is a combination of warm and cool air. As the sun beats down, the surface of the earth gets warmer due to which the air surrounding that region heats up. This warm air known as thermal has the tendency to move up towards the cooler region. As the warm air rises, the water vapors in the air cools down and forms the cloud. It continues to rise until its temperature becomes same as that of surrounding. The cloud gets bigger as the air rises.
The temperature of top surface of the cloud is below freezing point which turns the water vapors into ice. The lower surface of the cloud is warmer which contains water droplets. So it’s the ice crystals at the top and water droplets at the bottom of the cloud. They collide with each other during storm which creates static electric charges in the cloud. More collision eventually results in cloud being filled with electric charges. The positive charges are lighter thus remain at the upper surface of the cloud and negative are heavier which reside at the bottom. When these charges grow large enough they get repelled towards the opposite charge which causes the spark. These charges can move either from cloud to cloud or from cloud to earth.