Bottom line:
1. The tax law is clear. In the absence of any pre-2009 divorce decree or separation decree (irrelevant if the parents were never married), the custodial parent has the absolute right to claim the child as a dependent on his or her tax return. To the IRS, the custodial parent is the parent with whom the child spent the greater number of nights during the tax year.
2. The non-custodial parent may not claim the child on his tax return unless the custodial parent relinquishes his/her right, by completing IRS Form 8332 and giving it to the non-custodial parent. <a rel="nofollow" target="_blank" href="
https://www.irs.gov/pub/irs-pdf/f8332.pdf">https://www.irs.gov/pub/irs-pdf/f8332.pdf</a>
3. In the absence of Form 8332, if the custodial and the non-custodial parent each file tax returns claiming the same child, the IRS (as Hal_Al explained earlier) will honor the custodial parent's claim, and will reject the claim of the non-custodial parent.
In theory, a judge could order the custodial parent to relinquish his/her right to claim the child. That would introduce legal ramifications that are outside the realm of this tax forum. The IRS would not involve itself in such issues.
**Answers are correct to the best of my ability but do not constitute tax or legal advice.