Madonna and Rocco Ritchie
Madonna has been rebuilding her realtionship with her eldest son, but has agreed that he will now live with his father in London Getty

Director Guy Ritchie has been granted custody of his son Rocco after settling a court dispute with his ex-wife, singer Madonna. A spokesman for the New York State court system said the pair had reached an agreement regarding the permanent residence of the 16-year-old, just hours before a scheduled court appearance was due to take place.

Ritchie's lawyer Peter Bronstein confirmed that Rocco would continue to live with his father in London but will regularly visit his mother in the US, reported BBC News.

According to Page Six, speaking outside the British director's home, Bronstein said: "The case is settled and everyone agrees that Rocco's needs changed and he's going to be living with dad. Everyone's agreed to that and there's no further need for any kind of a court case."

The former couple became embroiled in a legal battle after Rocco fled the European leg of his mother's Rebel Heart tour and ignored a court order to fly back to live with his mother in New York. Rocco remained instead in London with his father and his new wife Jacqui.

Rocco spent Christmas with his father and was even enrolled in a school in the capital, despite his mother's requests that he return to the States to begin the new school term.

In December, a judge ruled that Rocco should return to his mother, but decided not to issue a warrant to enforce the order, urging the warring parents to reach an amicable agreement and prevent further stress to their son.

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."

In March, Ellen Sigal, Rocco's court-appointed lawyer, said that the dispute was causing him undue stress. "It's been a very difficult time for him," she said in court. "We hope to put an end to this as soon as possible without exposing him to more litigation, press innuendo, any of that kind of thing."

Madonna broke down on stage in Auckland saying she accepted that she had 'lost the battle,' to win back her eldest child. "There's no love stronger than a mother for her son," she said.

Madonna custody battle
Madonna has agreed for ex-husband Guy Ritchie to have custody of her son Rocco Madonna/ Instagram

However, at the end of the tour, the singer went to London to rebuild her relationship with her son and establish a more cordial bond with her ex husband, whom she married in 2000 and divorced in 2008.

The 58-year-old singer has recently been spending more quality time with Rocco, treating him to a late-night, sold out performance of stage show You Me Bum Bum Train in London. In July, the teenager also accompanied the mother-of-four to Malawi in Africa, on a family trip with his siblings David and Mercy who were born there.

In August, the Material Girl singer treated Rocco to a lavish 16<sup>th birthday, reportedly spending $50k to fly him and his friends to New York in a private jet.

Madonna's lawyer has declined to comment on the custody agreement, according to a report by Mail Online .