Beyond Discovery

Physics

How Magnets Work

Why do magnets stick, attract and repel? Learn how spinning electrons, magnetic domains and electric currents create magnetism, with a safe compass to build.

By Beyond Discovery 9 min read

Illustration of a horseshoe magnet with iron filings showing magnetic field lines
Illustration

Hold two magnets close together and you can feel something strange: a push or a pull across empty space, with nothing visibly touching. Flip one magnet around and the push becomes a pull. It feels almost like a hidden spring, and children (and plenty of adults) can spend a long time just playing with that invisible tug.

That everyday sensation leads straight to some of the deepest ideas in physics. Magnetism comes from the behavior of electrons inside atoms, it is inseparable from electricity, and it shapes everything from the needle of a camping compass to hospital scanners and the protective bubble around our planet.

This guide explains where magnetism comes from, why only some materials are magnetic, how electricity and magnetism are linked, and how you can build a working compass with things from the kitchen drawer.

The rules every magnet follows

Before getting into atoms, it helps to know the basic behavior that every magnet shares:

  • Every magnet has two poles, called north and south. The names come from compasses: the end of a freely hanging magnet that swings toward Earth's north is its "north-seeking" or north pole.
  • Opposite poles attract and like poles repel. North pulls on south; north pushes away north.
  • Poles always come in pairs. Snap a bar magnet in half and you do not get a lone north and a lone south. You get two smaller magnets, each with its own north and south pole. Physicists have searched for an isolated magnetic pole (a "monopole") for decades without finding one.
  • The force weakens quickly with distance. Move a magnet a little farther away and its pull drops off sharply, which is why a fridge magnet holds a sheet of paper but slips off a thick menu.

The region around a magnet where its influence can be felt is called its magnetic field. You cannot see a field, but you can map it. Sprinkle iron filings on a sheet of paper laid over a magnet and they line up along curved paths running from one pole to the other. Those paths are the field lines physicists draw in diagrams.

N S
Field lines leave a magnet's north pole and loop around to its south pole. Where the lines crowd together, near the poles, the field is strongest.

Where magnetism really comes from

Every magnet is ultimately made of atoms, and every atom contains electrons. Electrons have two properties that make them tiny magnets. They carry electric charge, and moving charge produces a magnetic field. More importantly, each electron has an intrinsic property called spin, which gives it a built-in magnetic moment, as if it were a microscopic bar magnet with its own north and south.

In most atoms, electrons pair up with opposite spins, so their magnetic effects cancel. Atoms with unpaired electrons keep a leftover magnetic moment. That is the first ingredient.

The second ingredient is cooperation. In a handful of materials, notably iron, cobalt and nickel, a quantum-mechanical effect makes neighboring atoms prefer to line up their magnetic moments in the same direction. Materials that behave this way are called ferromagnetic, from the Latin word for iron.

Magnetic domains

Even in a lump of iron, the atoms do not all point the same way across the whole piece. Instead, the metal is divided into small regions called magnetic domains. Inside each domain, billions of atoms are aligned, but neighboring domains point in different directions, so an ordinary iron nail shows no overall magnetism.

Bring a strong magnet close, and domains that point roughly along its field grow at the expense of the others. The nail becomes a temporary magnet and can pick up paper clips. Take the magnet away, and in "soft" iron the domains drift back toward random arrangements. In "hard" magnetic materials, such as the alloys used in permanent magnets, the domains stay aligned, and the magnet keeps its strength for years.

Why heat ruins a magnet

Heat makes atoms jiggle. Above a certain temperature, called the Curie temperature after the French physicist Pierre Curie, that thermal motion overwhelms the tendency of atoms to align, and the material loses its ferromagnetism. For iron, this happens at about 770 °C. Dropping or hammering a magnet can also knock domains out of alignment and weaken it.

Magnetic, non-magnetic, and in between

People often assume "metal" means "magnetic", but most metals are not noticeably attracted to a fridge magnet. Aluminum foil, copper wire, gold rings and most coins will not stick.

Type of behaviorWhat happens near a magnetExamples
FerromagneticStrongly attracted; can become magnets themselvesIron, nickel, cobalt, many steels, magnetite
ParamagneticVery weakly attracted; effect vanishes when the magnet is removedAluminum, oxygen, platinum
DiamagneticVery weakly repelledWater, copper, carbon (graphite), bismuth

Paramagnetic and diamagnetic effects are real but typically far too weak to notice without sensitive equipment or very powerful magnets. Researchers have used extremely strong laboratory magnets to levitate small objects that contain lots of water, because water is weakly diamagnetic.

If you want to explore which elements are which, our interactive periodic table is a good place to look up iron, cobalt and nickel and see where they sit among the transition metals.

Electricity and magnetism: two sides of one force

For centuries, magnetism and electricity seemed unrelated. Then, in 1820, the Danish physicist Hans Christian Ørsted noticed that a wire carrying electric current made a nearby compass needle swing. A current, he showed, produces a magnetic field that circles around the wire.

Within about a decade, Michael Faraday had demonstrated the reverse: moving a magnet near a coil of wire, or changing the magnetic field through it, pushes an electric current around the coil. This effect, called electromagnetic induction (Faraday reported it in 1831), is how nearly all of the world's electricity is generated today. Spinning magnets and coils inside power-station generators and wind turbines turn motion into current. You can read more about how these discoveries unfolded in our history of the discovery of electricity.

Later in the 19th century, James Clerk Maxwell unified the two in a single mathematical theory of electromagnetism, which also revealed that light itself is an electromagnetic wave.

Electromagnets

Because current creates a magnetic field, you can build a magnet you can switch on and off. Wrap insulated wire around an iron nail, connect the ends to a battery, and the nail becomes a magnet as long as current flows. The iron core concentrates the field produced by the coil. Electromagnets lift scrap cars in junkyards, ring doorbells, drive loudspeakers and turn electric motors. If you have built a simple electric circuit, an electromagnet is a natural next project with an adult's help.

Earth: a planet-sized magnet

In 1600 the English physician William Gilbert published De Magnete, arguing that Earth itself behaves like a giant magnet. He was right, although the cause is not a solid bar of iron inside the planet (the deep interior is far too hot for permanent magnetism). Instead, Earth's field is generated by the slow churning of molten, electrically conducting iron in the outer core, a process known as the geodynamo.

At the surface, Earth's field is weak: roughly 25 to 65 millionths of a tesla (microteslas), depending on where you are, according to the NOAA World Magnetic Model. A typical fridge magnet produces a field roughly a hundred times stronger right at its surface. The field still matters enormously:

  • Navigation. Magnetic compasses were in use in China by the 11th century and later spread to Europe, transforming sea travel.
  • Protection. The field deflects much of the stream of charged particles from the Sun, the solar wind. Some particles are funneled toward the poles, where they collide with the upper atmosphere and create auroras.
  • Animal navigation. Many animals, including some birds, sea turtles and fish, appear to sense Earth's field and use it to find their way, although exactly how they do so is still being studied.

One curiosity: because opposite poles attract, the magnetic pole near Earth's geographic North Pole is, in physics terms, a magnetic south pole. That is why a compass needle's north end points toward it. The magnetic poles also wander over time, which is why navigation systems rely on regularly updated models of the field.

From fridge doors to hospital scanners

Field strength is measured in teslas. A few comparisons give a sense of scale:

SourceApproximate field strength
Earth's field at the surface0.000025–0.000065 tesla
Typical fridge magnetA few thousandths of a tesla
Hospital MRI scannerCommonly 1.5–3 tesla
Strongest steady-field research magnetsAround 45 tesla

Powerful permanent magnets became cheap and common after the development of neodymium-iron-boron magnets in the early 1980s. These "rare-earth" magnets sit inside headphones, phone speakers, computer hard drives, electric-vehicle motors and wind-turbine generators. At the other end of the scale, MRI scanners use superconducting electromagnets to align hydrogen nuclei in the body and build detailed images; our archive story on the physics behind MRI explains how.

Try this: build a floating compass

You will need: a steel sewing needle, a strong fridge magnet or bar magnet, a small piece of cork or a plastic bottle cap, a shallow bowl of water.

  1. Magnetize the needle. Hold the needle by its eye. Stroke it about 30–50 times with one end of the magnet, always in the same direction (from eye to point), lifting the magnet away between strokes.
  2. Make a float. Lay the needle on the cork or bottle cap. An adult can press it gently into a slice of cork, or you can simply rest it on top.
  3. Float it. Set the float in the middle of the bowl, away from metal objects and electronics.
  4. Watch. The float will slowly turn until the needle settles along a north-south line. Check its direction against a phone compass app.
  5. Test it. Bring the magnet near the bowl and watch the needle swing toward or away from it, depending on which pole you use.

What is happening? Stroking the needle with a magnet lines up many of its magnetic domains, turning it into a weak magnet. Floating it on water removes friction, so Earth's gentle field can rotate it.

Safety: An adult should handle the needle with younger children. Keep small, powerful magnets (especially neodymium magnets and magnetic toy pieces) away from babies and young children: if two or more are swallowed, they can attract each other through the walls of the intestines and cause serious injury that needs emergency care. Keep strong magnets away from pacemakers and other medical implants, and away from bank cards and older electronics.

Key ideas to take away

  • Magnetism comes from electrons, mainly from their spin. In ferromagnetic materials, atoms line up in domains, and aligned domains make a magnet.
  • Magnets always have two poles; opposite poles attract and like poles repel.
  • Electricity and magnetism are two faces of one force: currents make magnetic fields, and changing magnetic fields drive currents.
  • Earth's magnetic field comes from moving molten iron in the outer core, guides compasses and helps shield the planet.

Questions to explore together: Why might a compass behave oddly near a steel radiator? If you cut a magnet into ten pieces, how many poles would you have? Can you find magnets hidden in household objects, such as cupboard catches, speakers or toys? For more experiments and explanations like this, browse our physics articles.

Sources and further reading