britney spearsBritney Spears‘ custody battle with ex-husband Kevin Federline has officially ended.

The settlement - which sees Kevin gaining sole physical and legal custody of their two sons - was signed by a judge on Friday after over 18 months of court hearings, following the couple’s separation in late 2006. Britney’s visitation is not mentioned in the agreement but if she stays on track, her current three sessions, including one overnight, a week with the boys will increase to include a second overnight stay by the end of the year.

Britney’s lawyer Laura Wasser told People magazine that Britney was “thrilled” that the settlement was reached before they were forced to go to a full trial: “It was a victory for the whole family that they don’t have to go to a trial.

“I think they figured out a way to work together, to co-parent and make sure their kids will benefit from the result of that.

“To have more time with her kids has been her motivation to get well. In light of her outstanding conservatorship, she couldn’t have asked for anything more.”

Kevin’s lawyer Mark Vincent Kaplan added that the former dancer is “very happy” with the deal and the increase in child support payments: “Kevin is delighted to have this ordeal over. He is greatly relieved and very happy this worked out.”

As part of the settlement, Britney also agreed to pay $250,000 of Kevin’s legal custody costs.

The couple’s sons, Sean and Jayden, turn 3 and 2 respectively in September.