Kevin Winter/Getty Images via ABCMadonna and her ex-husband Guy Ritchie have settled their custody case over their son Rocco, according to court records obtained by ABC News.

The exes had been scheduled to appear in court in New York City on Wednesday, but instead were able to reach an agreement out of court.

New York State Supreme Court Judge Deborah Kaplan, the presiding judge in the case, had implored the Queen of Pop and her director ex, who split in 2008 after eight years of marriage, to settle the dispute, which dates back to December.

At that time, Rocco, now 16, left his mother’s Rebel Heart tour to live with Ritchie in London. Madonna appealed to a New York court for his return. Although Judge Kaplan ordered Rocco to return to New York, she was unwilling to issue a warrant when he did not.

Rocco remained in London, where he was enrolled in school, while his parents tried to work out a deal. In March, a court-appointed attorney representing Rocco told the court the teen was stressed over the situation.

Mother and son were finally reunited in London in May. The following month, they were spotted at an off-Broadway show in New York. Last month, Rocco accompanied his famous mother to Cuba to celebrate her recent 58th birthday.

“In my Universe there are 2 Suns!” she wrote on Instagram, captioning a photo of Rocco and her other son, David. “Best Birthday ever!”

In a statement to ABC News, Guy Ritchie’s attorney Peter Bronstein said that the director “is delighted to have this case behind him,” adding, “Everybody is in the family is happy that an agreement has been reached and Rocco can continue to live with his father in London.”

Copyright © 2016, ABC Radio. All rights reserved.