Lightning is caused by the separation of positive and negative charges within thunderstorm clouds. As ice crystals collide within the clouds, electrons are transferred, leaving the top of the cloud positively charged and the bottom negatively charged. When the negative charge at the bottom of the cloud is attracted to the positive charge in the ground, a stepped leader forms to connect them. This stepped leader travels from the cloud to the ground in sections, with pauses in between. Once connected, a return stroke allows the flow of electrons from the cloud and positive charges from the ground, producing a visible lightning strike. The rapid heating and expansion of air during this process causes thunder.