Britney Spears ended her battle on Thursday to win back custody of her two young sons from ex-husband Kevin Federline, Federline's attorney Mark Vincent Kaplan told FOXNews.com on Friday.

"Last night we reached an agreement that would prevent the case from going to trial," Kaplan told FOXNews.com at Los Angeles Superior Court, where a hearing in the custody battle had just wrapped up.

At a press conference shortly afterward, Kaplan said, "The agreement has been reached and it will be turned into a legal document in the near future." He did not want to comment on the actual terms.

Spears' lawyer Laura Wasser told FOXNews.com that Spears is doing great, and that she has her kids today and will have them tonight and is very happy.

Kaplan earlier told OK! magazine that both Spears, 26, and Federline, 30, reached and signed off on a settlement in their custody case.

"At about 8 p.m. PT, a final settlement in the Kevin Federline-Britney Spears custody case was signed. All parties have agreed to the following: Kevin will retain sole legal and physical custody of Sean Preston and Jayden James. Britney will continue to have visitation rights which may increase over time. The agreement will be presented to the court in the morning for approval by the commissioner.

"Kevin is ecstatic and the boys are thriving," Kaplan added.

A court spokesman said Friday that no formal settlement had been filed.

In Touch magazine reported that according to the terms of the agreement, Spears will continue to have monitored visitation with her sons two days a week and one overnight.

Those visitations could periodically increase, one day at a time, until custody is shared equally with Federline — but only if Britney's father, Jamie Spears, continues to serve as her conservator. Without Jamie Spears' oversight, Spears would be forced to adhere to the current, much stricter guidelines to earn more time with her kids.

Spears lost custody of Sean Preston, 2, and Jayden James, 1, to Federline last October. At the time she had visitation privileges, but they were severely restricted following her January hospitalization for psychiatric evaluation.

Click here for the OK! magazine report

Click here for the In Touch report

Click here for myfoxla.com

FOXNews.com's Hollie McKay contributed to this report.