You need cold air and warm air. When they meet, the warm air goes up. It makes thunderstorm clouds! The cold air has ice crystals. The warm air has water droplets. During the storm, the droplets and crystals bump together and move apart in the air. This rubbing makes static electrical charges in the clouds.
Just like a battery, these clouds have a "plus" end and a "minus" end. The plus, or positive, charges in the cloud are at the top. The minus, or negative, charges are at the bottom. When the charge at the bottom gets strong enough, the cloud lets out energy.
The energy goes through the air. It goes to a place that has the opposite charge. This lightning bolt of energy that is let out is called a leader stroke. It can go from the cloud to the ground. Or, a leader stroke can go from the cloud to another cloud. No one is sure why lightning bolts follow a zigzag path as they move. The main bolt or stroke will go back up to the cloud. It will make a flash of lightning. It will also heat the air. The air will spread quickly. It will make the sound we hear as thunder.