Lightning is the flash of light in the sky caused by an electric current. The current may flow between parts of the same cloud, between different clouds or between clouds and the earth.
When a thundercloud becomes charged, the whole cloud has a charge. The cloud actually consists of an immense number of tiny water droplets with each droplet having a charge on its surface. If the cloud comes near an opposite electric charge, a huge spark may result. When a charged cloud comes near the surface of the earth, an opposite charge is induced on the surface of the earth. The air that separates the cloud and the earth acts as an insulator. It resists the efforts of the opposite charges of electricity to rush together. But when the electrical potential becomes large enough, it overcomes the resistance and a flash occurs.