During a thunderstorm clouds can build up to a height of about 12km, inside these clouds you can have a mixture of water, hailstones and ice crystals. Air within the cloud is also rising and falling in strong currents. Because the water and hail have different weights they "knock against each other" and as the hail falls through the rising air carrying the lighter water droplets they remove positive electical charge and so over a large area you have an excess in negativly charged hail FALLING through the clouds and an excess of positively charged water RISING in the clouds. This difference in electrical charge causes the huge lightning flash. The thunder is the heat generated by the lightning expanding and then contracting the air around the spark producing a pressure wave experienced as a loud bang or long rumble depending on how far away the lightning is from the observer.
The difference in the size of the spark in a discharging battery, as mentioned earlier, to the size of the spark in lightning is due to the voltages involved. A typical car battery is 12 volts and can produce a spark about 1mm long, where as a lightning bolt can be a billion volts (1 000 000 000) and produce sparks well in excess of 1km.