What causes the 'sprites' seen in certain weather phenomena?

I don't believe anyone really knows. These are seen at the tops of major thunderstorm 'anvil' clouds, and appear to contain electrons and ions accelerated to very high energies. In fact, as I understand it, the electromagnetic emission from these 'sprites' has even been detected at gamma ray energies! We know that thunder clouds can produce bolts of lightning in which the electrostatic potential within these clouds can strip electrons from atoms and accelerate then to energies of many 1000s of electron volts. Evidently, a similar process occurs at the top of the thunder cloud to accelerate ions to even higher energies. So far as I understand it, no one really knows just how this is done.