In the image above, the Sun is more than ten thousand Earth diameters off to the left. The solar wind, blowing away from the Sun at between 200 and 600 miles per hour, streams past the Earth, dragging part of the sun's magnetic field into space, to form the interplanetary magnetic field. As the charged particles in the solar wind encounter the Earth's magnetic field, they are slowed, and their motions curve around the magnetic field lines, in loops whose size depends upon the mass of the particles, their speed, their charge, and the strength of the field. If the loops are large, the particles can run into the outer atmosphere of the Earth, but if they are small, they tend to be funneled toward the north or south magnetic poles. A continual rain of charged particles bombards the upper atmosphere near the poles, creating a permanent, but faint aurora -- the aurora borealis or Northern lights near the North Pole, and the aurora australis or Southern lights near the South Pole. Particles whose loops are middling in size tend to get 'tangled up' in the field lines near the Poles, and bounce back and forth from pole to pole, forming a semi-permanent plasma, in the 'trapping region'.
Far off to the left, the solar wind particles are streaming away from the Sun, unaffected by the Earth's magnetic field. Near the Earth, as described above, they are strongly affected by the field. In between are regions where various 'boundary' effects occur. This can be compared to a traffic accident on a freeway (the interaction of the solar wind with the Earth's field, near the Earth). Traffic may still be flowing smoothly far away from the accident (well off to the left of the Earth), but at some point, cars slow down and move more slowly. The magnetosheath corresponds to this region, while the bow shock represents the point where cars might be able to escape the traffic jam by taking alternate routes.
At the same time that solar wind particles are being slowed and trapped by the Earth's magnetic field, they are escaping. Some of the particles bouncing from pole to pole exchange energy with other particles, allowing a slow leakage from the trapping region (the Van Allen radiation belts), into the atmosphere. Others are dragged away from the Earth, into interplanetary space. Since the Earth's magnetic field slows the solar wind and traps it, it must be exerting a net sunward force on the particles in the wind. According to Newton's Third Law, those particles must also push on the field, compressing it and making it stronger on the sunward side, and stretching it out into a magnetotail (which extends as much as a thousand Earth radii beyond the Earth). As shown in the diagram, in the magnetotail, field lines which would normally run north and south get stretched out along the line away from the Sun. In the region shown as the neutral sheet, lines running away from the Earth and toward the Earth can be very close together. As the solar wind strengthens and weakens, the tail can 'blow' in the wind, one way or the other, twisting the magnetic field lines. Under these circumstances, it would hardly be surprising if, as in a flag twisting in the wind, the lines were to cross. But magnetic field lines cannot cross, because their direction is the direction that a compass needle would point, and it cannot point in two directions at once. So if they were to try to cross, they would instead combine, forming elliptical loops, which would be blown away from the Earth and Sun, along with any plasma trapped inside them, into the vast reaches of interplanetary space.
So far, we have discussed two ways of letting the trapped particles escape -- allowing some of them to fall into the atmosphere, and others to blow out into space. But there is a third mechanism, as well. As the Earth rotates, charged particles in the sunward region compressed toward the Earth rotate around the Earth, into the region on the magnetotail, and rush away from the Earth, along with the magnetotail. But although some of them manage to escape, as noted above, most are doomed to be dragged back toward the Earth, as it continues to rotate, and they are thrust back from the far reaches of the magnetotail, toward the compressed regions closer to the Earth. In particular, charged particles in the region about a sixth to a third of the way from the Earth to the Moon may be thrown back at the Earth by the change in the field caused by the Earth's rotation with such force that they smash through the magnetic field lines near the poles, forming especially bright auroral displays from a few hours before dawn, until shortly afterward.
Between the various ways that charged particles escape from the magnetic field, on the average, particles arrive from the Sun, and are flung into our atmosphere or lost to space, at about the same rate. When the solar wind blows faster and more densely, more particles run into our atmosphere, creating more intense auroral displays; while when the solar wind blows slower or less densely, fewer particles run into our atmosphere, creating less intense displays. And when, on rare occasions, a gigantic explosion on the Sun throws immense numbers of particles at us, we experience spectacular auroral displays, and strong electromagnetic fields induced throughout our atmosphere by the interaction of the dense solar plasma and our magnetic field -- the so-called "geomagnetic storms".