Magnetic fields can be produced by moving electric charges and the intrinsic magnetic moments of elementary particles associated with a fundamental quantum property, their spin. Magnetic fields and electric fields are interrelated, and are both components of the electromagnetic force, one of the four fundamental forces of nature.
In everyday life, magnetic fields are most often encountered as a force created by permanent magnets, which pull on ferromagnetic materials such as iron, cobalt, or nickel, and attract or repel other magnets.
Magnetic fields are widely used throughout modern technology, particularly in electrical engineering and electromechanics. The Earth produces its own magnetic field, which shields the Earth's ozone layer from the solar wind and is important in navigation using a compass. Rotating magnetic fields are used in both electric motors and generators. Magnetic forces give information about the charge carriers in a material through the Hall effect. The interaction of magnetic fields in electric devices such as transformers is studied in the discipline of magnetic circuits.
Although magnets and magnetism were known much earlier, the study of magnetic fields began in 1269 when French scholar Petrus Peregrinus de Maricourt mapped out the magnetic field on the surface of a spherical magnet using iron needles. Noting that the resulting field lines crossed at two points he named those points 'poles' in analogy to Earth's poles. He also clearly articulated the principle that magnets always have both a north and south pole, no matter how finely one slices them.
Almost three centuries later, William Gilbert of Colchester replicated Petrus Peregrinus' work and was the first to state explicitly that Earth is a magnet. Published in 1600, Gilbert's work, De Magnete, helped to establish magnetism as a science.
In 1750, John Michell stated that magnetic poles attract and repel in accordance with an inverse square law. Charles-Augustin de Coulomb experimentally verified this in 1785 and stated explicitly that the north and south poles cannot be separated. Building on this force between poles, Siméon Denis Poisson (1781–1840) created the first successful model of the magnetic field, which he presented in 1824. In this model, a magnetic H-field is produced by 'magnetic poles' and magnetism is due to small pairs of north/south magnetic poles.
Three discoveries challenged this foundation of magnetism, though. First, in 1819, Hans Christian Ørsted discovered that an electric current generates a magnetic field encircling it. Then in 1820, André-Marie Ampère showed that parallel wires having currents in the same direction attract one another. Finally, Jean-Baptiste Biot and Félix Savart discovered the Biot–Savart law in 1820, which correctly predicts the magnetic field around any current-carrying wire.