Even if you can't claim your child as a dependent, he or she is treated as your qualifying person if:
The child was under age 13 or wasn't physically or mentally able to care for himself or herself,
The child received over half of his or her support during the calendar year from one or both parents who are divorced or legally separated under a decree of divorce or separate maintenance, are separated under a written separation agreement, or lived apart at all times during the last 6 months of the calendar year,
The child was in the custody of one or both parents for more than half the year, and
You were the child's custodial parent.
The custodial parent is the parent with whom the child lived for the greater number of nights in 2016. If the child was with each parent for an equal number of nights, the custodial parent is the parent with the higher adjusted gross income.
**Mark the post that answers your question by clicking on "Mark as Best Answer"
The IRS has it's own definition of custodial parent that is not he same as court ordered custody or agreements. The IRS only goes by physical custody - where the child physically lived more then half the year.
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).
See Custodial parent and noncustodial parent under the residency test in Pub 17
<a rel="nofollow" target="_blank" href="https://www.irs.gov/publications/p17/ch03.html#en_US_2016_publink1000170897">https://www.irs.gov/pub...>