The connections between magnetism and electricity were discovered in the early part of the 19th cent. In 1820 H. C. Oersted found that a wire carrying an electrical current deflects the needle of a magnetic compass because a magnetic field is created by the moving electric charges constituting the current. It was found that the lines of induction of the magnetic field surrounding the wire (or any other conductor) are circular. If the wire is bent into a coil, called a solenoid, the magnetic fields of the individual loops combine to produce a strong field through the core of the coil. This field can be increased manyfold by inserting a piece of soft iron or other ferromagnetic material into the core; the resulting arrangement constitutes an electromagnet.
Following Oersted's discovery the various magnetic effects of an electric current were extensively investigated by J. B. Biot, Félix Savart, and A. M. Ampère. Ampère showed in 1825 that not only does a current-carrying conductor exert a force on a magnet but magnets also exert forces on current-carrying conductors. In 1831 Michael Faraday and Joseph Henry independently discovered that it is possible to produce a current in a conductor by changing the magnetic field about it. The discovery of this effect, called electromagnetic induction, together with the discovery that an electric current produces a magnetic field, laid the foundation for the modern age of electricity. Both the electric generator, which makes electricity widely available, and the electric motor, which converts electricity to useful mechanical work, are based on these effects.
Another relationship between electricity and magnetism is that a regularly changing electric current in a conductor will create a changing magnetic field in the space about the conductor, which in turn gives rise to a changing electrical field. In this way regularly oscillating electric and magnetic fields can generate each other. These fields can be visualized as a single wave that is propagating through space. The formal theory underlying this electromagnetic radiation was developed by James Clerk Maxwell in the middle of the 19th cent. Maxwell showed that the speed of propagation of electromagnetic radiation is identical with that of light, thus revealing that light is intimately connected with electricity and magnetism.