Lightning is an electrical discharge that moves through the clouds in a thunderstorm. A thundercloud in the sky has many frozen droplets of water in the form of small pieces of ice. When wind blows, the frozen droplets collide with each other and become electrically charged by friction. This give rise to a whole cloud filled up with electrical charges. In general the positive charges form at the top of the cloud and the negative charges form near the lower edges of the cloud.
A positive charge area builds up below the cloud on the ground due to friction with wind and rain, and there is accumulation of positive charges near the ground and on tree tops. The attraction between the charges may be great enough to cause electrons to jump the air gap between the objects. Once the few electrons start across the gap, they heat up the air such that more and more electrons jump across the gap. This heats the air even more. It all happens very fast, and the air gets so hot that it glows for a short time. This cause a spark and we see it as lightning.