Spears, 25, caused a media frenzy when she arrived at court in jeans, a black satin top and sunglasses hours after the start of a hearing at which her lawyers had asked permission for the pop singer to spend nights with the boys.
It was the first time Spears had shown up for proceedings over the future of Sean Preston, two, and Jayden James, one.
She lost custody of the boys last week to her ex-husband, Kevin Federline, after failing to comply with court orders for random drug and alcohol testing.
Spears had previously shared custody with Federline, but is currently only allowed to see the boys during supervised daytime visits.
Dozens of photographers and camera crews swarmed Spears's white Mercedes as she arrived at Los Angeles Superior Court for the closed-door hearing.
She left about an hour later without speaking to reporters.
Federline was not present.
A Los Angeles Superior Court spokesman said the presiding judge gave Spears permission to spend one night a week with the boys under the supervision of a court monitor.
Before Spears's arrival, Los Angeles Superior Court Commissioner Scott Gordon had said he saw no reason to change the terms of the child custody order.
Spears's lawyer said the singer wanted her mother, Lynne, to act as monitor for the overnight visits.
It was not clear whether the court granted this request.
Media reports have said Spears reconciled recently with her mother after a bitter six-month estrangement.
Federline's lawyer, Mark Vincent Kaplan, said Federline had approved the change.
"Mr Federline has always been willing to jointly parent these children ... with certain conditions in place," Mr Kaplan told reporters.
Spears and Federline split a year ago, after two years of marriage.
Her life has since veered out of control, despite a stint in rehab. © 2007 Australian Broadcasting Corporation