An electromagnet is a type of magnet
A magnet is a material or object that produces a magnetic field. This magnetic field is invisible but is responsible for the most notable property of a magnet: a force that pulls on other ferromagnetic materials, such as iron, and attracts or repels other magnets.A permanent magnet is an object...

 in which the magnetic field
Magnetic field
A magnetic field is a mathematical description of the magnetic influence of electric currents and magnetic materials. The magnetic field at any given point is specified by both a direction and a magnitude ; as such it is a vector field.Technically, a magnetic field is a pseudo vector;...

 is produced by the flow of electric current
Electric current
Electric current is a flow of electric charge through a medium.This charge is typically carried by moving electrons in a conductor such as wire...

. The magnetic field disappears when the current is turned off. Electromagnets are widely used as components of other electrical devices, such as motor
Motor is a device that creates motion. It usually refers to an engine of some kind. It may also specifically refer to:*Electric motor, a machine that converts electricity into a mechanical motion...

s, generator
Generator may refer to:* Electrical generator* Engine-generator, an electrical generator, but with its own engine.* Generator , any of several closely related usages in mathematics.Computing:...

s, relay
A relay is an electrically operated switch. Many relays use an electromagnet to operate a switching mechanism mechanically, but other operating principles are also used. Relays are used where it is necessary to control a circuit by a low-power signal , or where several circuits must be controlled...

s, loudspeaker
A loudspeaker is an electroacoustic transducer that produces sound in response to an electrical audio signal input. Non-electrical loudspeakers were developed as accessories to telephone systems, but electronic amplification by vacuum tube made loudspeakers more generally useful...

s, hard disk
Hard disk
A hard disk drive is a non-volatile, random access digital magnetic data storage device. It features rotating rigid platters on a motor-driven spindle within a protective enclosure. Data is magnetically read from and written to the platter by read/write heads that float on a film of air above the...

s, MRI machines
Magnetic resonance imaging
Magnetic resonance imaging , nuclear magnetic resonance imaging , or magnetic resonance tomography is a medical imaging technique used in radiology to visualize detailed internal structures...

, scientific instruments, and magnetic separation
Magnetic separation
Magnetic separation is a process in which magnetically susceptible material is extracted from a mixture using a magnetic force. This separation technique can be useful in mining iron as it is attracted to a magnet....

 equipment, as well as being employed as industrial lifting electromagnets for picking up and moving heavy iron objects like scrap iron.
An electric current flowing in a wire creates a magnetic field around the wire (see drawing below).