The magnetosphere is the region above the ionosphere and extends several tens of thousands of kilometers into space, protecting the Earth from the charged particles of the solar wind and cosmic rays that would otherwise strip away the upper atmosphere, including the ozone layer that protects the Earth from harmful ultraviolet radiation.