Britney Spears must hand over custody of her sons Sean Preston and Jayden James to Kevin Federline this week "until further notice," a judge ruled Monday after a hearing.
The judge gave no reasons in his written decision, issued after he met lawyers in a session requested by Kevin Federline's lawyer, Mark Vincent Kaplan.
K-Fed gets custody starting Wednesday.
The ruling comes after the filing of misdemeanor charges against Britney Spears - hit-and-run and driving without a valid license - and claims by her ex-bodyguard, Tony Barretto, that she used drugs, frequently got naked and is a danger to her children, Sean Preston, 2, and Jayden James, 1.
A judge also said Britney is a "habitual, frequent and continuous" user of alcohol and controlled substances, and ordered her to submit to twice-weekly testing.
The singer, who has 50-50 custody with Federline, was seen around town with Sean Preston and Jayden James over the weekend, and on Sunday they had an early dinner in Malibu, as a crush of celebrity news people camped outside.
"She seemed fine," said Tony Koursaris, owner of the restaurant, Taverna Tony's, where she dined. "She was very comfortable having dinner here with her boys... The kids had a good time. Then we had to fight the paparazzi, of course."
It's really, really difficult for a mother to lose all custody of her children, but Britney Spears has always been extremely talented. And insane. Never count her out!
The photographers, however, did come in handy at one point over the weekend. Around midnight Saturday, her Mercedes ran out of gas during a food run.
Taking a break from trying to snap celebrity pictures of Britney Spears with no pants, some paparazzi went to a gas station and helped her gas up her Benz.