This process is called static discharge.
The same phenomenon is involved when a person rubs their feet on a carpet and then receives an electric shock when they come into contact with an object that conducts electricity. The rubbing causes an accumulation of electrons. In the clouds, this is achieved via the contact of small particles with one another. The conductor then provides a pathway to a region where a positive charge has been induced due to the negative charge in the other object.