Lighting can only form when clouds have different charges at the top and bottom. In the top part of the cloud, the charge is positive, while the bottom half of the cloud builds up a negative charge. This negative charge is attracted to the positive charge in the ground below the cloud, so the cloud creates a stepped leader of negatively charged particles that zigzag through the air toward the ground. This stepped leader is not the bright flash of the lightning bolt, but merely a pathway of negatively charged air that the lightning bolt will soon follow. The stepped leader doesn't progress all at once, but instead moves in a zigzag pattern, traveling up to 150 feet in one direction before pausing and heading about 150 feet in another direction.
The lightning bolt itself is a discharge of electricity from the ground up to the cloud in reaction to the negatively charged ladder that is reaching down from the sky. It forms when a streamer of positively charged particles reaches up toward the steeped leader that is heading down toward it from the cloud. The steeped leader and streamer meet about 150 feet off the ground or off the top of a protruding object, such as a treetop, rooftop antenna or steeple. Once the two bands meet, they form a channel through which electricity can travel. The actual bolt of lightning can contain up to a billion volts of electricity and may flicker as it travels up the charged path to the cloud up to 20 times in rapid succession.
When you see a flash of lightning, a loud peal of thunder follows soon afterward. This is because the electrical discharge heats up the air around it to temperatures five times as high as the surface of the sun. The air expands and vibrates in response to this blast of heat, letting out a loud clap. Because thunder moves at the speed of sound, it reaches you after the lightning flash, which travels at the faster speed of light. After the blast of lightning, the cloud continues to discharge by sending out smaller stepped leaders of negatively charged air along the same path that the original step ladder followed.
The idea that lightning never strikes twice in the same spot is fairly well-known, but it's a myth. Also, what appears to be a single lightning strike is often multiple strikes or multiple branches that hit in different places at the same time. Lightning doesn't need to travel between a cloud and the ground, either. Lightning bolts develop between the negatively charged bottom of one cloud and the positively charged top of another cloud far more frequently than lightning between earth and sky.