The hearing began behind closed doors.
Spears, 25, and Federline, 29, previously had shared custody of the boys. But Monday's court order for Spears to temporarily surrender 2-year-old Sean Preston and 1-year-old Jayden James to Federline came after the pop star failed to produce a California driver's license and allegedly missed a court-ordered drug and alcohol test, her lawyer, Sorrell Trope, told People magazine.
A temporary driver's license was issued to Spears late Tuesday, California Department of Motor Vehicles spokesman Mike Marando said Wednesday.
"She has completed her requirements for a driver's license," he said.
Among her recent problems, Spears was charged with misdemeanor counts of hit-and-run and driving without a valid license for allegedly crashing into a parked car in August.
Spears and Federline were married in October 2004. She filed for divorce last November, and it became official in July.
The judge previously ordered Spears to undergo random drug and alcohol testing twice a week after the court found she engages in "habitual, frequent and continuous use of controlled substances and alcohol."
He also previously ordered Spears to meet weekly with a "parenting coach" who was to report back to the court about her skills. Both Spears and Federline must complete the court's "Parenting Without Conflict" class.
Since splitting with Federline, Spears has been photographed several times without underwear, shaved her head, beat a car with an umbrella and eventually spent a month in rehab.
An MTV Video Music Awards performance intended as a comeback was criticized, with Spears appearing lethargic. The following week, her management firm dropped her, and her divorce lawyer resigned.