This article is from the Fusion FAQ, by Robert F. Heeter email@example.com with numerous contributions by others.
If you add up the masses of the particles which go into a fusion
reaction, and you add up the masses of the particles which come out,
there is frequently a difference. According to Einstein's famous
law relating energy and mass, E=mc^2, the "mass difference" can
take the form of energy. Fusion reactions involving nuclei lighter
than iron typically release energy, but fusion reactions involving
nuclei heavier than iron typically absorb energy. The amount of
energy released depends on the specifics of the reaction; a table
of reactions is given further below to give an idea of the variety
of fusion reactions.
Another way to look at this is to consider the "binding energy"
of the elements in question. If the reactants are bound more
weakly than the products, then energy is released in the reaction.
"Binding energy" is the amount of energy you would have to put
into a system in order to pull its components apart; conversely,
in a system with high binding energy, a lot of energy is released
as the components are allowed to bond together. Suppose you
had two balls connected by a long, thin rubber band, so that they
are not very tightly connected, and the rubber band can be broken
easily. This is a system with low binding energy. Now here's an
analogy to what happens in fusion: imagine the long, thin
rubber band suddenly being replaced by a short, thick one. The
short thick one has to be stretched a lot in order to connect
to the two balls, but it wants to bind them more tightly, so it
pulls them together, and energy is released as they move towards
each other. The low-binding energy, long rubber band system
has been replaced by a high-binding energy, short rubber band
system, and energy is released.