A relay is a mechanical device that connects one circuit to another. It should be thought of as a switch. Think of two electrical circuits that are joined via a relay. When current flows into the primary circuit from a power source, that current causes another switch to be thrown (the relay) and power now flows into a secondary circuit as well. However, this can be done in reverse, so that when power is no longer flowing in the primary circuit it trips a relay, and power comes from a secondary circuit. This is the way that automatic generators work during power outages to make sure that the flow of electricity isn't interrupted.
While the above relay works off of electrical energy, that doesn't mean all relays do. Pneumatic relays are those which are attached to circuits that conduct compressed air rather than a flow of electrons, however the principle is the same. The difference is that in these systems, when the presence of compressed air is flowing through one circuit, the force of that energy opens up a switch and begins to flow into a second circuit. In both of these varieties though, as well as in any other types of relay, there needs to be a sensor present so that the switching can occur.
While there are a number of different kinds of relay (electrical, pneumatic and even hydraulic), that doesn't mean that all varieties are mutually exclusive. Many machines will use combination relays. In these machines electrical power might trip a relay switch that will create mechanical energy (such as using electricity to create a magnetic force that will physically pull a switch closed). In other relays mechanical energy may be used to signal that an electrical current needs to start or stop (such as an air compressor whose sensor detects that pressure has reached a certain threshold in the tank, so it opens the circuit to power off the actual compressor).
- Power plant image by MAXFX from Fotolia.com