- it is an exergonic reaction itself, and
- it couples itself to the endergonic reaction, so that the overall reaction is exergonic.
The body's ingenious solution is to use another exergonic process to drive the non-spontaneous (endergonic) one. More accurately, it couples the exergonic reaction with the endogonic one so that the free energy released from the former reaction propels the latter one.
For its chosen exergonic reaction, the body generally uses the hydrolysis of ATP (adenosine triphosphate). This is the major 'energy' molecule produced by metabolism, and it serves as a sort of 'energy shuttle': ATP is dispatched to wherever an endergonic reaction needs to take place, and the two reactions are coupled so that the overall reaction is thermodynamically favoured.
To make this more concrete, let's look at the synthesis of Glutamine. This molecule is produced in the following manner:
Glutamic acid + Ammonia → Glutamine
Unfortunately, this reaction is non-spontaneous (ΔG = +3.4 kcal/mol). However, ATP is at hand. The hydrolysis of ATP (ATP + H2O → ADP + Pi) is highly exergonic - (ΔG = -7.3). As you can see if these reactions could somehow be coupled, together the overall reaction would be favoured: ΔG would be -3.9. And so, with the help of ATP, the body can synthesise glutamine without breaking any thermodynamic laws.
But to return to our original question, how exactly is this coupling achieved? The basic answer is this: when ATP is hydrolysed, the free phosphate group (Pi) isn't wasted. Instead, it is transferred to some other molecule, such as the reactant. The molecule is thus phosphorylated. However, this phosphorylated molecule is thereby rendered unstable - it is 'keen' to react all of a sudden. And this new-found tendency allows the desired reaction to take place.
To help make this clearer, I've drawn a diagram of the Glutamic acid + Ammonia → Glutamine reaction above. The big blue molecule is glutamic acid; the other players in the drama are labelled.
In the first stage, the reactants are in place, but since the reaction is non-spontaneous, they are powerless to get going. ATP arrives to help out.
In the second stage, ATP is hydrolysed to ADP + Pi. However, the phosphate group binds to the glutamic acid molecule (phosphorylates it). This phosphorylated intermediate is more reactive than the glutamic acid was by itself.
In the final stage, the ammonia group displaces the phosphate one. This reaction is spontaneous, thanks to the phosphate group making the complex in stage 2 more unstable. Thus, ATP allows glutamine to be formed via two spontaneous reactions, but the price to be paid is that the ATP molecule has been used up - it has been hydrolysed to ADP and Pi.
There are many other examples of ATP's action, but in almost all cases a substance is phosphorylated. As always, this phosphorylated intermediate is more reactive than the original reactant, and so what was once an endergonic reaction is thus rendered exeronic by the coupling of the original reaction with the hydrolysis of ATP.
Source: "Biology", 7th Edn., Campbell & Reece