Here's a breakdown:
* Earth acts like a giant magnet: Our planet has a magnetic field that extends far out into space. This field is generated by the movement of molten iron in Earth's core.
* Magnetic poles and geographic poles: Earth's magnetic field has two poles, a north magnetic pole and a south magnetic pole. These poles are not exactly aligned with the Earth's geographic poles (north and south).
* Compass needle alignment: A compass needle is itself a small magnet. It aligns itself with the Earth's magnetic field lines. Since opposite poles attract, the north end of the compass needle points towards the Earth's north magnetic pole.
Important note: The Earth's magnetic north pole is not fixed and drifts over time. This means that a compass doesn't point directly to true north (geographic north), but to magnetic north, which can be a few degrees off.