Our understanding of Earth's magnetic field began with the discovery of magnetite, which is naturally magnetized and aligned with the magnetic poles. Over centuries, scientists like Peregrinus, Gilbert and Maxwell studied magnetism and developed theories about Earth's magnetic field. The modern theory is that Earth's magnetic field is generated by dynamo action in the liquid outer core, where convection of electrically conducting fluids interacts with the planet's rotation to act like a self-exciting dynamo. Dynamo theory remains the accepted explanation but does not explain all observations of Earth's magnetic field such as polarity reversals.