One of the first drawings of a magnetic field, by
, 1644, showing the Earth attracting lodestones. It illustrated his theory that magnetism was caused by the circulation of tiny helical particles, "threaded parts", through threaded pores in magnets.
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.
[nb 1] 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.
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 repel 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.
Extending these experiments, Ampère published his own successful model of magnetism in 1825. In it, he showed the equivalence of electrical currents to magnets
 and proposed that magnetism is due to perpetually flowing loops of current instead of the dipoles of magnetic charge in Poisson's model.
[nb 2] This has the additional benefit of explaining why magnetic charge can not be isolated. Further, Ampère derived both
Ampère's force law describing the force between two currents and
Ampère's law, which, like the Biot–Savart law, correctly described the magnetic field generated by a steady current. Also in this work, Ampère introduced the term
electrodynamics to describe the relationship between electricity and magnetism.
Michael Faraday discovered electromagnetic induction when he found that a changing magnetic field generates an encircling electric field. He described this phenomenon in what is known as
Faraday's law of induction. Later,
Franz Ernst Neumann proved that, for a moving conductor in a magnetic field, induction is a consequence of Ampère's force law.
 In the process, he introduced the
magnetic vector potential, which was later shown to be equivalent to the underlying mechanism proposed by Faraday.
Lord Kelvin, then known as William Thomson, distinguished between two magnetic fields now denoted H and B. The former applied to Poisson's model and the latter to Ampère's model and induction.
 Further, he derived how H and B relate to each other.
The reason H and B are used for the two magnetic fields has been a source of some debate among science historians. Most agree that Kelvin avoided M to prevent confusion with the SI fundamental unit of length, the
Metre, abbreviated "m". Others believe the choices were purely random.
Between 1861 and 1865,
James Clerk Maxwell developed and published
Maxwell's equations, which explained and united all of
classical electricity and magnetism. The first set of these equations was published in a paper entitled
On Physical Lines of Force in 1861. These equations were valid although incomplete. Maxwell completed his set of equations in his later 1865 paper
A Dynamical Theory of the Electromagnetic Field and demonstrated the fact that light is an
Heinrich Hertz experimentally confirmed this fact in 1887.
The twentieth century extended electrodynamics to include relativity and quantum mechanics.
Albert Einstein, in his paper of 1905 that established relativity, showed that both the electric and magnetic fields are part of the same phenomena viewed from different reference frames. (See
moving magnet and conductor problem for details about the
thought experiment that eventually helped Albert Einstein to develop
special relativity.) Finally, the emergent field of
quantum mechanics was merged with electrodynamics to form
quantum electrodynamics (QED).