Why Magnets Attract and Repel Each Other: Explained

Magnets attract or repel each other because of how their magnetic fields interact. When two opposite poles (north and south) face each other, their fields merge and pull the magnets together. When two identical poles (north-north or south-south) face each other, their fields push apart. This behavior traces back to the electrons inside the magnet’s atoms and how they collectively create a force that reaches across empty space.

Where Magnetic Force Comes From

Every electron has a tiny magnetic field of its own. This field comes from an intrinsic property called spin, a quantum mechanical trait that gives each electron a small magnetic moment. It’s tempting to picture the electron literally spinning like a top, but that model doesn’t hold up. The magnetic moment is simply a built-in feature of the electron, confirmed by experiments like the Stern-Gerlach experiment in the 1920s, which showed electrons deflecting in a magnetic field in only two directions: “spin up” or “spin down.”

In most materials, electrons are paired so that their spins point in opposite directions and cancel each other out. The material has no net magnetic field and can’t act as a magnet. But in certain elements, notably iron, cobalt, and nickel, atoms have unpaired electrons whose magnetic moments don’t get canceled. These leftover moments give each atom a small but real magnetic field.

How Atoms Team Up Into Domains

A single atom’s magnetic field is far too weak to stick a note to your fridge. What makes a piece of iron into a usable magnet is organization. In ferromagnetic materials, groups of atoms band together into regions called magnetic domains. Within each domain, which can contain billions of atoms, every atom’s magnetic moment points in the same direction. The tiny fields add up instead of canceling out, creating a miniature magnet within the larger piece of metal.

In an unmagnetized piece of iron, domains point in random directions, so the material as a whole has no net field. But when you expose that iron to an external magnetic field (by stroking it with another magnet, for instance), domains aligned with the field grow at the expense of misaligned ones. Eventually most or all domains point the same way, the piece of iron develops a clear north and south pole, and you have a permanent magnet.

Why Opposite Poles Pull Together

A magnet’s field flows in curved lines from its north pole, arcing through space, and looping back into its south pole. When you bring the north pole of one magnet near the south pole of another, those field lines connect. They flow seamlessly from one magnet into the other, becoming denser in the gap between them. This merging of fields creates a pulling force that draws the two magnets together, just as two complementary puzzle pieces lock into place.

The denser those field lines become in the gap, the stronger the attractive force. That’s why the pull feels strongest right before the magnets snap together.

Why Like Poles Push Apart

Bring two north poles (or two south poles) close together and the opposite happens. Both sets of field lines are flowing outward in the same direction, and they can’t merge. Instead, the lines bend away from each other, creating a zone of high pressure between the magnets. The result is a repulsive force that pushes the magnets apart. You can feel this as a spongy resistance when you try to force two same-facing fridge magnets together.

The underlying physics is symmetrical: attraction and repulsion are the same interaction, just with different geometry. Flip one magnet around and the force switches direction instantly.

How Distance Affects the Force

Magnetic force drops off sharply with distance. For everyday magnets, which physicists treat as dipoles (objects with two poles), the field strength decreases roughly with the cube of the distance. Double the gap between two magnets and the force falls to about one-eighth of what it was. This is steeper than gravity or the electric force between point charges, both of which follow an inverse-square law. It’s why a magnet can yank a paperclip from a centimeter away but has almost no effect from across the room.

Why Only Some Materials Are Magnetic

Not every material responds to a magnet, and the ones that do respond in different ways. Materials fall into three broad categories based on their electron structure.

  • Ferromagnetic materials (iron, cobalt, nickel, and their alloys) have domains that can align permanently. They produce strong magnetization even after an external field is removed, which is why they can become permanent magnets. Their magnetization is large enough to saturate in moderate fields at room temperature.
  • Paramagnetic materials (aluminum, platinum, some stainless steels) have unpaired electrons but no domain structure. They’re weakly attracted to a magnet while the field is present, but the attraction vanishes the moment the field is removed. Their response is thousands of times weaker than a ferromagnet’s.
  • Diamagnetic materials (copper, water, wood, bismuth) have all their electron shells filled, with no unpaired electrons at all. When exposed to a field, they develop a tiny opposing magnetization. In other words, they’re very slightly repelled by magnets. The effect is so faint it’s almost undetectable without sensitive instruments.

Heat Can Destroy a Magnet

Permanent magnets stay magnetized because their domains are locked in place by interactions between neighboring atoms. Heat adds energy that shakes those atoms, gradually randomizing the domain alignment. Every ferromagnetic material has a specific temperature, called its Curie temperature, where it loses its magnetism entirely. For iron, that threshold is 770°C. Cobalt holds up longer at 1,115°C, while nickel gives in earlier at 354°C. Above these temperatures, the material becomes paramagnetic and only weakly responds to external fields. Cool it back down and it can be remagnetized, but any permanent magnetism it had before is gone.

Electromagnets Use the Same Principle

Permanent magnets aren’t the only way to generate attraction and repulsion. In the early 19th century, Hans Christian Oersted discovered that an electric current flowing through a wire deflects a compass needle. This was the first evidence that moving charges and magnetism are related. Wrap that wire into a coil and you get an electromagnet, which produces field lines nearly identical to those of a bar magnet, complete with north and south poles that attract and repel just like permanent ones.

The key difference is control. Turn off the current and the field disappears. Reverse the current and the poles flip. This makes electromagnets essential in electric motors, MRI machines, maglev trains, and speakers, all of which depend on rapidly switching between attraction and repulsion. The underlying force, though, is the same one that makes two bar magnets snap together on your fridge: interacting magnetic fields created, at the smallest scale, by the behavior of electrons.