Magma contains magnetic particles, such as particles bearing iron. As the magma flows, the magnetic particles line up with Earth's magnetic field. As the magma cools and hardens, the magnetic particles are locked in place.
Didn't find the answer you were looking for?