Britney spears has agreed to hand the parenting reins over to Kevin Federline.
K-Fed's longtime attorney Mark Vincent Kaplan exclusively tells E! News that the divorced duo have reached a settlement in their long-gestating custody case.
According to the agreement signed by all parties, Federline gets sole legal and physical custody of sons Sean Preston and Jayden James and Spears will have visitation rights.
"The case has been settled," Kaplan said. "The court still has to approve it. " Both parties are due in court Friday morning.
The case had been set to go to trial next month but all had been hoping to settle up beforehand.
"As of this evening there is a fully executed deal memo...All the issues that would have been addressed at trial have been settled," Kaplan told E! News. "Can't speak to the exact terms of the deal. Orders in place...will stay in place."
But although this is theoretically good news for Federline, Kaplan maintains that this isn't exactly what his client had in mind.
"Kevins was not [out] to get custody. Kevins goal was to set up some kind of template so the mother of his children can co-parent," Kaplan said.
"He said I need to have Britney to be involved in the coparenting of the kids but I need there to be a structure."
But this is the structure he got and "Kevin is absolutely delighted," Kaplan continued.
"Nobody could have anticipated the terms of events that have occurred....This was a two-year journey that will be halted at a point that is good for these children. Custody is always modifiable. If there is a final order, it means there is nothing to try."
Spears has been enjoying monitored visits with her boys since late February after temporarily losing any on-hand-mommying privileges following a stretch of noticeably erratic behavior on her part and two brief hospital stays.
Federline's camp has credited the influence of Spears' father Jamie, who was appointed a coconservator of his daughter's estate Feb. 1, for helping to get the 26-year-old popster back on track.
A court commissioner is scheduled to review whether the make the conservatorship permanent at the end of this month. If the arrangement were to end, what then happens to Spears' current deal?
"While I can't tell you the terms, the order does anticipate what happens if the conservatorship is ended," Kaplan told E! News. "The devil is always in the details and this is a very detailed deal memo.
"Nobody can predict what the future will bring but ...to the extent possible I think we have really anticipated how to proceed."