Thunder is the sound caused by lightning. Depending on the distance and nature of the lightning, it can range from a sharp, loud crack to a long, low rumble (brontide). The sudden increase in pressure and temperature from lightning produces rapid expansion of the air surrounding and within a bolt of lightning. In turn, this expansion of air creates a sonic shock wave, similar to a sonic boom, often referred to as a "thunderclap" or "peal of thunder".
A short sample of a crack of thunder during the sound of falling rain
Problems playing this file? See media help.
The cause of thunder has been the subject of centuries of speculation and scientific inquiry. The first recorded theory is attributed to the Greek philosopher Aristotle in the fourth century BC, and an early speculation was that it was caused by the collision of clouds. Subsequently, numerous other theories were proposed. By the mid-19th century, the accepted theory was that lightning produced a vacuum.
In the 20th century a consensus evolved that thunder must begin with a shock wave in the air due to the sudden thermal expansion of the plasma in the lightning channel. The temperature inside the lightning channel, measured by spectral analysis, varies during its 50 ?s existence, rising sharply from an initial temperature of about 20,000 K to about 30,000 K, then dropping away gradually to about 10,000 K. The average is about 20,400 K (20,100 °C; 36,300 °F). This heating causes a rapid outward expansion, impacting the surrounding cooler air at a speed faster than sound would otherwise travel. The resultant outward-moving pulse is a shock wave, similar in principle to the shock wave formed by an explosion, or at the front of a supersonic aircraft.
Experimental studies of simulated lightning have produced results largely consistent with this model, though there is continued debate about the precise physical mechanisms of the process. Other causes have also been proposed, relying on electrodynamic effects of the massive current acting on the plasma in the bolt of lightning. The shockwave in thunder is sufficient to cause injury, such as internal contusion, to individuals nearby.
Inversion thunder results when lightning strikes between cloud and ground occur during a temperature inversion. In such an inversion, the air near the ground is cooler than the higher air. The sound energy is prevented from dispersing vertically as it would in a non-inversion and is thus concentrated in the near-ground layer. Inversions often occur when warm moist air passes above a cold front; the resulting thunder sound is significantly louder than it would be if heard at the same distance in a non-inversion condition.
The d in Modern English thunder (from earlier Old English þunor) is epenthetic, and is now found as well in Modern Dutch donder (cp Middle Dutch donre, and Old Norse þorr, Old Frisian þuner, Old High German donar descended from Proto-Germanic *þunraz). In Latin the term was tonare "to thunder". The name of the Germanic god Thor comes from the Old Norse word for thunder.
A flash of lightning, followed after some time by a rumble of thunder, illustrates the fact that sound travels significantly slower than light. Using this difference, one can estimate how far away the bolt of lightning is by timing the interval between seeing the flash and hearing thunder. The speed of sound in dry air is approximately 343 m/s or 1,127 ft/s or 768 mph (1,236 km/h) at 20 °C (68 °F). This translates to approximately 3 seconds per kilometer (or 5 seconds per mile); saying "One-Mississippi... Two-Mississippi..." (or "One One-thousand... Two One-Thousand...) is a useful method of counting the seconds from the perception of a given lightning flash to the perception of its thunder (which can be used to gauge the proximity of lightning for safety's sake). 
The speed of light is high enough that it can be taken as infinite in this calculation because of the relatively small distance involved. Therefore, the lightning is approximately one kilometer distant for every 3 seconds that elapse between the visible flash and the first sound of thunder (or one mile for every 5 seconds). In the same five seconds, the light could have traveled the Lunar distance four times. (In this calculation, the initial shock wave, which travels at a rate faster than the speed of sound, but only extends outward for the first 30 feet (9 m), is ignored.) Thunder is seldom heard at distances over 20 kilometers (12 mi). A very bright flash of lightning and an almost simultaneous sharp "crack" of thunder, a thundercrack, therefore indicates that the lightning strike was very near.
Media related to Thunder at Wikimedia Commons