This phenomenon results from the accumulation of electrical charges in cumulonimbus clouds
Lightning is usually produced by cumulonimbus clouds, which have 
bases ... thundercloud  the greater the accumulated charge, the higher the 
electrical field.