
I would suggest that you claim him on your return and submit the return with a letter explaining the circumstances. Include a copy of the court order. The IRS should respect the agreement that you entered into. If you find your self having a problem with the IRS, contact the Taxpayer Advocate section of the IRS. They can be very helpful.
The foregoing is not intended to be legal advice. It is highly recommended that you consult with an attorney.