After a closed-door hearing Monday, a judge ordered that, starting Wednesday, Kevin Federline will get physical custody of Sean Preston, 2, and Jayden James, 1, "until further order of the court."
L.A. Superior Court Commissioner Scott Gordon didn't outline his reasons in the written ruling, but Spears's attorney, Sorrell Trope, says, "We weren't able to prove compliance with what the judge ordered."
"Specifically," Trope says, "the judge ordered that by 10 a.m. (Monday) morning, both parties show valid California driving licenses. I've been unable to produce evidence of that."
Later Monday, after handing over her sons to a bodyguard of Federline's, Spears applied for a California driver's license in Van Nuys.
Spears, 25, has been charged with misdemeanor driving without a valid license and hit-and-run following a fender-bender in a store parking lot on Aug. 6.
Britney's Drug-Test IssueTrope says another reason behind the judge's temporary custody ruling "was a claim by Mr. Federline's attorney that she had not complied with a previous order the court had made – before I came on board (as lawyer) – about having a random drug and alcohol test."
Trope adds: "There's no evidence that she actually failed a test."
However, the courts see the failure to take a test as the same thing as not passing the test.
Another hearing is set for Wednesday.
Federline's attorney declined to comment in detail on the court proceeding. But a source close to Federline says he was "thrilled" after receiving news of the temporary custody change.
See Britney Spears video from CNN.com.
Who's turning 40? Which celebs are high school dropouts? What's hot and definitely not in fall fashion? Check out PEOPLE's new digital magazine now!