Who can claim the exemption and credits depends on who is the custodial parent. (By the IRS definition of custodial parent for tax purposes - this is not the same as the legal custody that a court might grant.).
The test that the IRS uses to determine the custodial parent is where the child lived for more than 1/2 (or greater part) of the year. The IRS will go so far as to require counting the nights spend in each household - that person is the custodial parent for tax purposes (if exactly equal and more than 183 days - The custodial parent is the parent with the highest AGI, if less than 183 days then neither parent has custody so the child cannot be claimed by either parent). And yes they are that picky.
See Custodial parent and noncustodial parent in Pub 501
Only the Custodial parent can claim: (Child would be listed as non-dependent EIC & CC only)
-Head of Household
-The Earned Income Credit
-The Child and Dependent Care Credit
-The Health Coverage Tax Credit
The non custodial parent can only claim: (Child would be listed as dependent)
- The child as a dependent
- The Child Tax Credit or credit for other dependents
But only if specifically specified in a pre-2009 divorce decree, separation agreement or the custodial spouse releases the exemption with a signed 8332 form - after 2009 the IRS only accepts a signed 8332 form that must be attached to the non-custodial parents tax return.
This does NOT mean that the custodial parent can ignore any Decree or court order allowing the non-custodial parent to claim the exemption - they can be required to issue the 8332 form. They could be required by the court to do so or be in contempt.