Lightning is caused by the accumulated charges in the cloud; hence this is a process of electric discharge.
During thunderstorms, air, current, and water droplets move vigorously in opposite directions. This movement results in the accumulation of negative charges near the lower edges of the cloud and positive charges towards the upper edges of the cloud.
Once a large magnitude of charges accumulates, the air being a poor conductor of electricity, allows charges to flow through it.
As the ground is positively charged, the negative charges near the lower edge of the cloud meet positive charges on the ground, producing streaks of bright light and sound.