Madonna, Guy Ritchie Child Custody Over Rocco Settled

9/7/2016 7:41 AM PDT

Madonna has settled her bitter custody fight over Rocco with ex-hubby Guy Ritchie ... TMZ has learned.

According to court docs, the exes were due in court Wednesday but hours before informed the judge they had resolved their differences.

As we reported, Madonna and Guy were at each other's throats over where Rocco would live. The 16-year-old bailed on Madonna's tour last December and began living with Guy in London. Madonna claimed Guy has poisoned her son against her.

The singer and Guy haven't gotten along for years, and fought constantly over child-rearing issues. She was the disciplinarian and she felt Guy was way too permissive.

It seemed they worked things out months ago. Madonna spent time with Rocco in London and he lived with her during part of the summer. He even partied with mom in Cuba a few weeks back for her birthday.

As for the terms of the settlement ... Guy's attorney told AP, Rocco will go back to London for school. Madonna will, no doubt continue to see her son frequently.