The Earth has a magnetic field, in many ways similar to a bar magnet.
Hopefully you played with a bar magnet in school. You sprinkle iron filings on a piece of paper and put the magnet underneath and the iron shavings rearrange themselves into a lovely set of curves, converging at the magnetic poles and spreading out more halfway between them. The overall shape is like an apple cut in half.
The Earth has a magnetic north pole and a magnetic south pole (not to be confused with the geographic, or rotational, poles) just like that bar magnet — we call this a dipole field. But the mechanism creating the magnetic fields between the two are way different.