Somebody realised that magnetic rocks (like the iron ore called magnetite), always point in the same direction, even when there are no magnetic materials nearby. Thus, the magnetic field must come from the Earth itself. This is the principle by which a compass needle always points to the North pole.
Comments