A compass works by detecting and responding to the Earth's natural magnetic fields. The Earth has an iron core that is part liquid and part solid crystal, due to gravitational pressure. It is believed that movement in the liquid outer core is what produces the Earth's magnetic field.
The natural magnetic fields of the Earth are detected and responded to by a compass. Due to gravitational pressure, the Earth's iron core is partially liquid and partly crystallized. The Earth's magnetic field is thought to be created by movement in the liquid outer core. The Earth's magnetic field, like all other fields, has two poles: north and south. However, even though the geographic and magnetic poles are slightly offset from one another, the compass can still be an extremely useful tool for navigation, especially when declination is taken into account to account for the slight polar differences.