According to the American Geophysical Union and reported at phys.org:
Dark lightning is a burst of gamma-rays produced during thunderstorms
by extremely fast moving electrons colliding with air molecules.
Researchers refer to such a burst as a terrestrial gamma-ray flash (TGF).
However, things are not quite so simple. There are actually several gamma ray phenomena related to thunderstorms.
According to Gamma-ray glow preceding downward terrestrial gamma-ray flash:
Two types of high-energy events have been detected from thunderstorms.
One is “terrestrial gamma-ray flashes” (TGFs), sub-millisecond
emissions coinciding with lightning discharges. The other is
minute-lasting “gamma-ray glows”. Although both phenomena are thought
to originate from relativistic runaway electron avalanches in strong
electric fields, the connection between them is not well understood.
The general thought is that electrons are accelerated to high speeds by the extreme electric field present around lighting but that's not yet a completely satisfying explanation.

Image from The Quest to Understand how Thunderstorms Create Gamma Rays
Capture of photonuclear neutrons is also a potential source of terrestrial gamma-ray flashes:
These results challenge TGF theoretical models based on runaway
electron acceleration. The TGF discharge electric field accelerates
particles over the large distances for which maximal voltages of
hundreds of megavolts can be established. The combination of huge
potentials and large electric fields in TGFs can efficiently
accelerate particles in large numbers, and we reconsider here the
photon spectrum and the neutron production by photonuclear reactions
in the atmosphere. Terrestrial Gamma-Ray Flashes as Powerful Particle Accelerators)
TGF Afterglows: A New Radiation Mechanism From Thunderstorms considers three different mechanisms at different time scales.

- "TGFs originate from cold runaway where thermal electrons accelerate to tens of MeV in the strong electric fields of a propagating leader discharge."
- "Glows ... would originate from relativistic runaway electron avalanches (RREA) with feedback of photons and positrons creating new avalanches..."
- "TGF afterglow ... when photons in the TGF are energetic enough to release neutrons from air molecules by a photonuclear reaction.... During thermalization they can be captured again by nuclei and sometimes with the release of a high-energy photon...."