The structure of the magnetosphere (NASA).
The region where the Earth's field predominates is the magnetosphere. The region where our field shares its effects with the solar field is the magnetosheath. The boundary between the two regions is the magnetopause. The region outside the bow shock is where the interplanetary (solar) field is predominant. The bow shock itself is remarkably compact. Just outside the bow the energy of solar wind particles corresponds to more than a million Kelvins (about 2 million Fahrenheit degrees). The energy of the particles drops to less than a third of that value in less than 100 miles, and half of that change occurs in the outermost 10 miles.
The Structure of the Magnetosphere and Its Interaction With the Solar Wind
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 that is compressed toward the Earth rotate around the Earth, into the region comprising the magnetotail, and rush away from the Earth, into 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 pulled 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; 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 -- so-called "geomagnetic storms".
Magnetic Field Reversals
The Earth's magnetic field is created by motions in the molten metallic core of the Earth. The mechanism is very complex, but the result is that the field is not permanent, but varies in strength and direction over time. Usually the changes in strength and direction are small, in periods as short as a century. But over longer periods of time (thought to be of the order of a thousand years or so), it is possible for the magnetic field to completely change its strength and direction, resulting in so-called "magnetic field reversals". During the last 80 million years of Earth history the magnetic field has been oriented in the opposite direction from its current direction. So what we think of as "normal" is actually a little less common in "recent" time than a "reversed" field, in which compass needles would point south instead of north. No one knows what happens to the field during the time that it changes from one direction to the other, as the last such time was the best part of a million years ago, and the physics involved is so complex that no theory's predictions can be considered certain. However, the field is probably a little weaker and much more complex than now at such times.
Timeline of normal (white) and reversed (black) magnetic fields for the Earth
(in millions of years before the present)