Britney Spears and ex husband Kevin Federline are parents to Jayden James and Sean Preston

Britney Spears has agreed to give ex husband Kevin Federline sole custody of their 2 sons.

The deal – which is expected to be given a judge's backing - means that a drawn-out court battle will be avoided next month.

‘The case has been settled,’ K-Fed's lawyer Mark Vincent Kaplan said last week. ‘The court still has to approve it. As of this evening there is a fully executed deal memo...

'All the issues that would have been addressed at trial have been settled. Can't speak to the exact terms of the deal. Orders in place...will stay in place.’

Britney, 26, will still have visitation rights – and though Kevin, 30, is 'absolutely delighted' with the agreement, it was an unexpected development, says Mr Kaplan.

‘Kevin was not [out] to get custody,’ he told E! Online. ‘Kevin’s goal was to set up some kind of template so the mother of his children can co-parent.

‘Nobody could have anticipated the terms of events that have occurred....'

Britney initially had joint custody of sons Sean Preston, 2, and Jayden James, 1, but full temporary custody was given to their dad in October 2007 because of the singer's unpredictable behaviour.

in January Brit, who was given court-monitored access, was hospitalised after she refused to hand back the kids after a visit to her home.

She was sectioned again less than a month later because mum Lynne feared she was suicidal.

Her dad Jamie, 55, is currently co-conservator of her estate and well-being.