The aurora starts at the Sun. A steady stream of charged particles — the solar wind — flows out across the solar system, gusting harder when the Sun hurls out a coronal mass ejection (CME). When that flow reaches Earth, our planet’s magnetic field deflects most of it, but some particles are funneled down the field lines toward the magnetic poles, which is why auroras ring the high latitudes in an oval rather than appearing everywhere at once.
As those particles plunge into the upper atmosphere, they collide with atoms and molecules of gas and transfer energy to them. The excited gas then sheds that energy as light. The color depends on which gas is hit and how high up: atomic oxygen glows green at around 557 nm near 100 km — the classic aurora color — and a deeper red at higher altitudes, while nitrogen contributes blue and purple, often along the lower edges and in active, fast-moving displays.
Most of the action happens roughly 100 to 300 km above the ground, far above clouds and weather. That height is also why the same display can be seen from places hundreds of kilometers apart, and why a curtain that looks overhead from one town appears low on the horizon from another.
Because the aurora forms an oval centered on each magnetic pole, there are really two auroras at once: the aurora borealis in the north and the aurora australis in the south, near-mirror images that brighten and expand together during a geomagnetic storm.