Lightning forms when opposite charges between a cloud and the ground or between two clouds develop. The charges have to be large enough to overcome the resistance of air to create a visible lightning spark. A single lightning strike can reach up to 100 million volts and generate temperatures five times hotter than the surface of the sun.
When thunderclouds form from a differential of warm and cold, it causes water vapor molecules to rub against ice crystals, stripping electrons that settle into some other atoms, creating electrical charge. The bottom of a cloud is negatively charged with electrons. The repelling force reaches the ground and makes it positively charged. These positive charges are attracted to the highest points possible. Streamers of particles gradually make their way between the cloud and the ground, and when they meet, the charge resolution is instantaneous. The bright flash of lightning is the result of the energy released when air molecules are subjected to electrical breakdown. The chaos of particle movement at the subatomic level gives lightning its characteristic forks and branches; electricity isn't taking a straight path. The massive heating of the air causes it to expand rapidly, creating a sonic boom known as thunder.