Negative charges gather near the base of the cloud, while positive charges build in the top of the cloud. This allows electric fields to form and grow between the cloud and the ground and within the cloud itself - all necessary conditions for lightning to occur.