LOS ANGELES, California (CNN) -- A court has ordered pop singer Britney Spears to give up custody of her children effective Wednesday at noon.
Spears' former husband, Kevin Federline, is to retain custody of their two sons "until further order of the court," according to a ruling by Superior Court Judge Scott Gordon.
It was not clear what led to Monday's decision awarding Federline full custody. A transcript of the court proceedings was ordered sealed.
Last month, a judge ordered Spears, 25, to submit to random drug tests after finding she engaged in "habitual, frequent, and continuous use of controlled substances and alcohol."
That order, also by Gordon, provided no details and did not name any drugs.
The former couple has been embroiled in a bitter custody fight over their sons, Sean Preston and Jayden. The parents had split custody 50-50, but Federline then asked for the arrangements to be shifted to 70-30 in his favor.
In addition to ordering the twice-weekly drug tests, Gordon ordered Spears to spend eight hours per week working with a "parenting coach," who was to observe her interactions with her children.
Gordon also told both parents to avoid alcohol or "other non-prescription controlled substances" 12 hours before taking custody of the children.
He also barred the exes from making "derogatory remarks about the other party and the other party's family or significant other" during the case.
And he ordered the parents to go through "joint co-parenting counseling" and barred them from using corporal punishment on the boys.
Spears and Federline were married for two years before their divorce became final in July.
Monday's order comes amid a career freefall for Spears, whose new album is due to be released November 13.
After her September 9 "comeback" performance on the MTV Video Music Awards, critics derided her singing and dancing as lackluster and said she appeared overweight in her sequined two-piece costume. Her former divorce lawyer, Laura Wasser, resigned last month as her legal representative after telling reporters the singer "just wants to be a mom."
Spears' management company, the Firm, recently quit after representing the singer for little over a month.