During the development of a thunderstorm, the air currents move upwards while the water droplets move downwards. These vigorous movements of air currents cause separation of charges.
The positive charges collect near the upper edges of the clouds and the negative charges accumulate near the lower edges. There is an accumulation of positive charges near the ground also.
When the magnitude of the accumulated charges becomes large, the air cannot resist their flow. As a result, negative and positive charges meet producing a streak of bright light and sound, called lightning.