The property of magnetism in the Earth is due to the presence of
Earth's magnetic field, also known as the geomagnetic field , is the magnetic field that extends from the Earth's interior to where it meets the solar wind, a stream of charged particles emanating from the Sun. Its magnitude at the Earth's surface ranges from 25 to 65 microteslas (0.25 to 0.65 gauss).
Roughly speaking it is the field of a magnetic dipole currently tilted at an angle of about 10 degrees with respect to Earth's rotational axis, as if there were a bar magnet placed at that angle at the center of the Earth.
Unlike a bar magnet, however, Earth's magnetic field changes over time because it is generated by a geo dynamo (in Earth's case, the motion of molten iron alloys in its outer core).