When a thunderstorm forms, the air around the storm becomes charged with electricity. Warm air rises from the ground and meets cooler air in the atmosphere. The difference in temperature creates an electric charge. The warm air rises faster than the cool air, so it has a positive charge. The cool air has a negative charge.
The charges separate and build up in the atmosphere until they eventually meet at the top of the storm cloud. When the positive and negative charges meet, they create a giant spark of electricity – this is called a lightning bolt.
Lightning can also occur between two clouds or between a cloud and the ground. When this happens, it's called intra-cloud Lightning or cloud-to-ground lightning.