Spears and Federline
Fame; Chris Weeks/WireImage
Britney Spears and Kevin Federline reached a divorce settlement Thursday, PEOPLE has learned.
"The parties signed a global settlement on all issues of their marriage and the custody of the children," Michael Sands, a spokesman for Federline's attorney Mark Vincent Kaplan, tells PEOPLE.
The deal was worked out in a five-hour meeting in the Los Angeles high-rise offices of Spears's attorney. At the table were Spears and Federline, along with Spears's lawyer Laura Wasser and Federline's counsel Kaplan and Jim Simon.
During a smoke break downstairs, Spears talked with Federline for 15 minutes, Sands said.
The terms were not revealed. A judge will still have to sign off on the agreement.
The deal comes just days after Spears left rehab on March 20.
Spears and Federline got married
in September 2004 in a surprise ceremony and soon settled into a Malibu mansion
The couple had two sons, Sean Preston in September 2005 and Jayden James almost a exactly a year later.
Not long after their second son was born, signs of trouble appeared in their marriage, with Spears missing many of Federline's promotional appearances for his poorly received hip-hop album Playing With Fire
Spears filed for divorce on Nov. 7, 2006, citing irreconcilable differences. In a temporary agreement, Spears had custody of the boys with three days of visitation for Federline.
The singer began months of hard-partying in New York, Miami, Las Vegas and Los Angeles, hooking up for a time with Paris Hilton
. She initially defended her partying
as long-overdue fun, but by January, her manager acknowledged she was having a rocky moment
After a wild weekend in which she shaved her head, Spears entered rehab
at Promises in Malibu, where she stayed for about four weeks. Federline, who watched the boys during her treatment, declined to return custody to Spears until he was satisfied with her post-rehab follow-through, according to a source.