During lightning storms previously observed by spacecraft, energetic electrons moving toward the craft slowed down and produced gamma rays.
That actually sounds like bremsstrahlung x-rays, not gamma rays. They have very different energy spectra due to their origin. Although you can also slow down the electrons by first producing an electron-positron pair, and then the positron will decay into two gammas.
Since the 1920s, up until a decade or so ago:
"Many investigators believed that the lower atmosphere was too dense for electrons to accelerate to speeds high enough to emit x-rays and other high-energy particles. Instead, they thought that lightning worked by conventional energy discharge--a bigger version of the spark that occurs when you touch a doorknob after trudging across the rug."
How thunderstorms work is still poorly understood. This building evidence is exciting a lot of new research and ideas. A lot of people are impressed that the earth can generate gamma rays of higher energy than those from the sun.
That actually sounds like bremsstrahlung x-rays, not gamma rays. They have very different energy spectra due to their origin. Although you can also slow down the electrons by first producing an electron-positron pair, and then the positron will decay into two gammas.