Britney Spears and her ex Kevin Federline have reached a custody settlement in their epic court battle over their two sons.
According to the agreement, which still needs to be signed off on by the court, Federline retains sole custody of the couple's two sons, Preston, 2 1/2, and Jayden, 1 1/2. Spears - who's currently allowed two visits and one overnight per week - will get more visitation rights.
"The case has been settled," Federline's attorney, Mark Vincent Kaplan (working with attorney James Simon), tells PEOPLE. "This is the end of a two-year journey."
Spears's attorney, Laura Wasser, said outside the courtroom after the hearing: "Britney's doing great. She's very pleased [with the settlement]. The kids are with her right now."
Without giving details, Wasser confirmed that Spears did win "more custodial time" with the boys.
The couple split in November 2006. The legal saga, which began with shared 50-50 custody in July 2007, took a dramatic turn when Spears – the pop powerhouse worth an estimated $100 million - was twice forcibly hospitalized early this year for mental health issues. (Her father Jamie stepped in to take legal control of her affairs.)
Though the couple averted a scheduled court trial with the settlement, a judge can always modify custody arrangements - and a source close to Spears tells PEOPLE the singer will likely get increased visitation as time goes on.
"Until the kids turn 18, we can expect in years to come that Britney and Kevin will be back in court," says L.A. family lawyer Lynn Soodik, who is not involved with the case. "Britney will have a better chance of winning more custody once she regains her health. This is just the end of Round One."