Rules for Qualifying
According to IRS rules, a child is the dependent of the parent he lives with most of the year. If your child spent exactly half the year with you and half with your ex, the IRS will give the dependency exemption to the parent with the highest adjusted gross income. Other rules apply as well. Your child can't pay for more than half of his own support needs, and if he lived with a third party at any point -- neither you nor his other parent -- it must have been for less than half the year.
Transferring the Exemption
The IRS allows parents to override its rules for dependency exemptions. If your ex is the custodial parent and your child lives with her most of the time, she can transfer her right to the exemption to you by signing IRS Form 8332. In some cases, a family court judge may order a custodial parent to do this. The exemption is then typically included in child support calculations, resulting in more child support payable to the parent who gives up the exemption.