The same magnetic interaction can run backward

A generator and an electric motor are closely related because both rely on the force between magnetic fields and electric currents. In a generator, motion changes the magnetic field passing through a coil of wire. That change pushes electric charges through the wire, producing current. In a motor, current flowing through coils creates magnetic fields that push or pull against nearby magnets, turning the motor’s moving part, called the rotor.

The key is that electricity and motion are linked in both directions. A generator supplies motion to the magnetic system and gets electrical energy out; a motor supplies electrical energy and gets motion out. The machine is not creating energy in either case—it is converting it from one form to another.

Why the reversal works

A coil in a magnetic field can experience a turning force when current flows through it. Reverse the arrangement, and moving the coil or magnet changes the magnetic field through the coil, inducing current. The same components can therefore act as either a source of electricity or a device that uses it.

In practice, motors and generators are designed for their particular jobs, and real machines lose some energy as heat and friction. Still, the shared mechanism is useful: some electric motors can operate as generators when an outside force turns them. In an electric vehicle, for example, the wheels can drive the motor during braking, sending some energy back into the battery instead of letting all of it become heat in the brakes.