How do compasses work?
A compass contains a magnetized needle, with a north pole at one end and a south pole at the other. Since opposite magnetic poles attract one another, the north pole of the compass is attracted toward any south poles it can find and the south pole of the compass is attracted toward any north poles it can find. The earth happens to have a strong south magnetic pole near its north geographical pole and a north magnetic pole near its south pole. As a result, compass needles turn (the experience torques) until their north magnetic pole ends are pointed northward (toward the south magnetic pole located there).