A spokesman for the New York State court system said the pair had reached an agreement, but did not reveal with which parent the teenager would live.
Ritchie's lawyer Peter Bronstein said Rocco would continue to live with his father in London.
The dispute arose in December when Rocco ignored a court order to fly back to live with his mother in New York. He has since stayed with his father in the UK capital and enrolled in a school there.
Madonna's lawyers have not commented on the settlement.
In December, a judge ruled that Rocco should return to his mother. But she decided not to issue a warrant to enforce the order, urging the pair to reach an agreement.
New York State Supreme Court Justice Deborah Kaplan said: 'No-one is disrupting his household other than the inability of the parents to reach a resolution. If they cannot resolve this matter then eventually the court will.'
Madonna and Ritchie married in 2000 and divorced eight years later.
From BBC News