Fox News host Bill O’Reilly will lose residential custody of his children following a New York appeals court ruling last week.

The Nassau County Supreme Court ruling upheld a lower-court decision that the kids, ages 13 and 17, should live with the Fox News Channel host’s ex-wife, Maureen McPhilmy, according to court documents obtained by TheWrap. The news was first reported by Gawker. O’Reilly and McPhilmy divorced in 2011 and have been battling for custody ever since. The lengthy ruling was finally rendered on Feb. 24.

Also Read: How Jeff Zucker Turned Donald Trump From a Reality Star to a Frontrunner (Video) “There is a sound and substantial basis for the Supreme Court’s determination that it is in the best interests of the children for the mother to be awarded primary residential custody,” the ruling says. The judgment awards full-time custody to McPhilmy, while granting O’Reilly a share of legal custody, allowing him equal say in material matters concerning the children. O’Reilly’s “The O’Reilly Factor” is the most-watched show on cable news.

Pamela Chelin contributed to this report.