Newton’s third law talks about conservation of energy. In the electromagnetic world, this is best manifest in the form of Lenz’s law, which states – “An induced electromotive force (emf) always gives rise to a current whose magnetic field opposes the original change in magnetic flux.”
To understand it in simple terms, the wire in the diagram experiences a downward force because the magnetic field of the permanent magnet reacts with the magnetic field created by the current flowing in the wire. If you were to reverse the direction of flow of current in the wire, the wire would move up instead. This is also called the motor effect, since this is the way motors work.
The wire (formed into a square loop), experiences a torque because the current flowing in the two arms of the loop are not in the same direction, causing the forces on the wire to be in opposite directions. The torque turns the wire loop. By having many such wire loops in its rotor, the motor is able to turn heavy loads.
Since there are two opposing magnetic fields operating when the motor turns, the speed of the motor is governed by the balance between the two. However, the two magnetic fields are never equal, as there is the mechanical friction of the bearings to be overcome to keep the motor rotating, and the difference between the two is called the Back EMF.
Although Back EMF is a good and necessary phenomenon that makes running of motors possible, it assumes menacing proportions in the operation of relays and solenoids. A relay or a solenoid consists of a coil or a large number of turns of wire on an iron core. One of the properties of such an arrangement is the coil stores energy when current passes through it. This, by itself, is nothing to worry about, unless the current is suddenly stopped. This is where you may want to read Lenz’s law again.
When the switch is opened, the current from the battery stops flowing instantly. However, the energy in the relay or solenoid “opposes the original change in magnetic flux”, which is now trying to collapse. The coil can do this only by keeping the current flowing across the gap in the switch. The only way it can do this is by creating a Back EMF high enough to generate an arc across the gap. The arc is sustained until the energy in the inductor dissipates.
Now, arcs in any form are dangerous, and the best way of handling them is to quench them as quickly as possible. In normal operation, a semiconductor switch such as a transistor replaces the resistor and switch shown, and is turned on or off to operate the relay. An arc can blow or damage a transistor in the fraction of a second.
The solution is rather simple. A flyback diode (also called a free-wheeling diode / snubber diode / suppressor diode / catch diode) is connected across the solenoid. When the switch is closed, the diode remains reverse biased and inactive. When the switch opens, the diode conducts to let the inductor current flow in an alternate path and limit the Back EMF to the forward voltage drop of a silicon diode (0.7V).