Baically in a relay there is a coil of wire with iron bar inside. Once you pass a current around the coil of wire a electro magnetic field is created and the iron bar is pulled into the coil. Once the current is cut off the electro magnetic field stops and a spring pushes the iron bar back out.
On the end of the iron bar is a set of switch contact, as the iron bar is pulled in and out of the coil of wire the contacts open and close.