The IRS allows the primary custodial parent, the one the child lives with for more than 50% of the year, to claim the child.
However, in many custody orders it is agreed that the parents will take turns claiming the child. In those cases, the CP signs a release of exemption form (8332) for...