The general rule is that exemptions for children of divorced parents go to the supporting parent who has physical custody of the children for more than half of the tax year. (IRC 152(e)) This rule applies in the absence of a contrary agreement.
In many cases that settle (and most do), the exemptions are the subject of negotiations and are shared between the parties. This sharing is done in several ways, usually by awarding each parent at least one (when there are more than one) and alternating years (when there is only one).
When sharing is agreed to, the specific arrangements are confirmed in the judgment of divorce, and the parties agree to execute the necessary tax forms (IRS Form 8332) to release the exemption from one parent to the other.