The magnetosphere is the layer of the atmosphere that acts like a magnet. It attracts charged particles from the Sun, known as the solar wind. These charged particles are deflected by the Earth's magnetic field and trapped within the magnetosphere, creating a protective shield around the planet.