The motion of energetic ions and electrons through space is strongly constrained by the local magnetic field. The basic mode is rotation around magnetic field lines, while at the same time sliding along those lines, giving the particles a spiral trajectory.
On typical field lines, attached to the Earth at both ends, such motion would soon lead the particles into the atmosphere, where they would collide and lose their energy. However, an additional feature of trapped motion usually prevents this from happening: the sliding motion slows down as the particle moves into regions where the magnetic field is strong, and it may even stop and reverse. It is as if the particles were repelled from such regions, an interesting contrast with iron, which is attracted to where the magnetic field is strong.