There are several qualifications that must be met for a child to be claimed as a dependent. These include relationship to the provider and the child's age. However, the child must also meet certain residency requirements with the parent trying to claim the child as a dependent. For this reason, the custodial parent in the case of divorced or separated parents claims the child for tax purposes. However, there are some situations in which the opposite is true.
The first qualification that must be met in this case is that the parents are legally separated, divorced, have lived apart for at least the last six months of the tax year and are under a "decree of divorce or separate maintenance." If this is true, the child must also have been in the custody of at least one parent and had more than half of his or her financial support from the parents in the relevant tax year.
However, it's important to remember that the terms of a court order take precedence. Most custody or support orders will specifically address which parent is to claim the child for tax purposes, and this is what needs to be followed. In the case that there are multiple children involved, the order may state that the parents can each claim different children. It's crucial to avoid issues with your or your ex's taxes later on that you make sure that you are claiming the correct children per your court order.
Each case is different. If you have questions about the terms of your court order or how you can make changes for next year, a family law attorney can help.
Source: Internal Revenue Service, "Publication 501 - Main Content," accessed Jan. 07, 2016