How are the northern lights produced?

The ionized particles from mainly solar wind are caught and trapped by Earth magnetic field, which behaves like a magnetic bottle. (The region in which ions are trapped is called Van Allen radiation belts.) This trap is weaker in the polar regions, and there the ions are mainly released into the denser parts of atmosphere. There they collide with air particles (mostly N$_2$ and O$_2$) causing their fluorescence seen as the northern lights.


The Solar wind flows past the Earth, interacting with the Earth's magnetic field, the magnetosphere. The boundary between the two, the magnetopause, is buffetted as the Solar wind isn't constant. Blobs of plasma can pass by, the upshot being that the magnetic fields get wound up, tangled if you like.

It has been found that magnetic fields can reconnect, this magnetic reconnection, can release an amount of energy heating the plasma. This is flows along the magnetic fields lines into the polar regions, colliding with the atmosphere and causing the lovely aurore.

It has been a while since I did my degree project on it. My memory may be fading, and I haven't kept up with geophysics for a while.