A court official confirmed Wednesday that the Material Girl and Ritchie had reached a settlement, according to the Associated Press. But no details of the agreement were made public.
Madge and the film director informed the judge that they resolved their differences just hours before they were set to appear in court on Wednesday, TMZ reported.
At the heart of the dispute was whether 16-year-old Rocco would continue living with his dad in London or with his mom.
Their legal showdown has been going on for years, with Madonna contending that Ritchie was too lenient with their son. Things came to a head in December when a New York judge granted Madonna's request to have Rocco return to New York from London after he reportedly skipped out on the remainder of her Rebel Heart Tour and refused to board a U.S.-bound plane from Britain.
In March, a judge urged the exes to find an amicable resolution for Rocco's sake.
Mother and son appear to have reconciled since then. She reunited with her firstborn son in London over the summer and he spent part of the season with her, going on a family vacation to Africa and celebrating the singer's 58th birthday with her in Cuba last month.
The Grammy winner and Ritchie, who split in 2008, co-parent Rocco and their adopted son David, 10. The singer is also mom to daughter Lourdes from another relationship and adopted daughter Mercy. Ritchie has three children with his current wife, Jacqui Ainsley.