Let us see what the book entitled Meteorology Today , says on this. It says that clouds become electrified as hail falls through a region in the cloud of supercooled droplets and ice crystals. As liquid droplets collide with hail, they freeze on contact and release latent heat. This keeps the surface of the hail warmer than that of the surrounding ice crystals. When the hail comes in contact with an ice crystal, an important phenomenon occurs.
Electrons flow from the colder object toward the warmer object.
Hence, the hail becomes negatively charged. The same effect occurs when super cooled droplets come in contact with a piece of hail and tiny splinters of positively charged ice break off. These lighter, positively charged particles are then carried to the upper part of the cloud by updrafts. The hail, left with a negative charge, fall toward the bottom of the cloud, thus the lower part of the cloud becomes negatively charged. These negative charges are then discharged to the ground as lightning.