A relay is an electromechanical device that uses an electric current to open or close the contacts of a switch. It consists of a coil that, when activated, attracts the contacts and pulls them together. When the coil is deactivated, a spring pushes the contacts apart.