The law of conservation of energy is an empirical law of physics. It states that the total amount of energy in an isolated system remains constant over time (is said to be conserved over time). A consequence of this law is that energy can neither be created nor destroyed: it can only be transformed from one state to another. The only thing that can happen to energy in a closed system is that it can change form: for instance chemical energy can become kinetic energy.
Albert Einstein's theory of relativity shows that energy and mass are the same thing, and that neither one appears without the other. Thus in closed systems, both mass and energy are conserved separately, just as was understood in pre-relativistic physics. The new feature of relativistic physics is that "matter" particles (such as those constituting atoms) could be converted to non-matter forms of energy, such as light; or kinetic and potential energy (example: heat). However, this conversion does not affect the total mass of systems, since the latter forms of non-matter energy still retain their mass through any such conversion.
Today, conservation of “energy” refers to the conservation of the total system energy over time. This energy includes the energy associated with the rest mass of particles and all other forms of energy in the system. In addition, the invariant mass of systems of particles (the mass of the system as seen in its center of mass inertial frame, such as the frame in which it would need to be weighed) is also conserved over time for any single observer, and (unlike the total energy) is the same value for all observers. Therefore, in an isolated system, although matter (particles with rest mass) and "pure energy" (heat and light) can be converted to one another, both the total amount of energy and the total amount of mass of such systems remain constant over time, as seen by any single observer. If energy in any form is allowed to escape such systems (see binding energy), the mass of the system will decrease in correspondence with the loss.
A consequence of the law of energy conservation is that perpetual motion machines can only work perpetually if they deliver no energy to their surroundings. If such machines produce more energy than is put into them, they must lose mass and thus eventually disappear over perpetual time, and are therefore not possible.