The District has agreed to the appointment of an independent overseer for its troubled juvenile justice system, moving the city one significant step closer to ending a long-running legal battle over how it treats young offenders.

With the agreement, filed yesterday in D.C. Superior Court, the city has for now averted a complete court takeover of the Youth Services Administration and the problem-plagued Oak Hill Youth Center, the city's juvenile jail and detention center.

For the District, which has worked aggressively under Mayor Anthony A. Williams (D) to bring agencies out of receivership, the agreement spares the city from seeing an agency taken over by a court-appointed administrator.

But until complaints about Oak Hill's conditions are resolved, the judge is keeping alive the threat to put a court-appointed receiver in charge. The ultimate decision-making authority over the agency and Oak Hill will now be in the hands of an independent arbiter.

"This is a real test of the commitment of Mayor Williams and the city administrator to improve and reform the juvenile justice system of the District," said Peter J. Nickles, a lawyer with Covington & Burling, who along with the D.C. Public Defender Service and the American Civil Liberties Union represents juveniles in the case.

Grace M. Lopes, who once served as the city's point person on reforming city agencies in receivership, will be the arbiter, according to the agreement, which was finalized this week by the two sides.

Lopes, who later served as general counsel to the mayor, left government last year to serve as managing director of the D.C. Appleseed Center for Law and Justice. Both sides praised her as independent and experienced.

Child advocacy groups, congressional leaders and others have lambasted Oak Hill, saying that the 188-bed facility in Laurel is poorly run. The conditions are so bad, the critics say, that juveniles held there are exposed to many of the same problems they encountered on the streets{ndash}from sexual violence to rodent infestation.

It was almost two decades ago that the suit, seeking an overhaul of the city's juvenile justice system, was filed on behalf of a youth identified in court papers as Jerry M. A consent decree, reached in 1986, was supposed to settle the suit, but problems persisted.

Under the agreement, the city and the plaintiffs will, under the supervision of Lopes, begin devising a plan to bring Youth Services into compliance with the consent decree and other court orders.

When differences arise, Lopes will be able to have the final say, according to the agreement. But unlike a receiver, who would not necessarily have to take input from the city -- or from the plaintiffs -- Lopes will be collaborating with the two sides and, ideally at least, not dictating to them.

"This fits in with what we've been saying all along: We don't need a receivership," said City Administrator Robert C. Bobb. "This represents the best of all worlds for the District. We and the plaintiffs are working jointly together, instead of fighting this out in court."

Once a plan is agreed upon, if Lopes finds that the District is not complying, the city will have 60 days to correct the problems. If she believes the city has failed to do so, that finding will on its own be "sufficient basis" for the appointment of a receiver by the court.

The city has had recurring problems in meeting court obligations. Just last month Judge Herbert B. Dixon Jr., who is overseeing the lawsuit at the center of the case, found the District in contempt of a consent decree governing operations at Oak Hill and issued fines.

Calls for change continued to come from many quarters, led by Sen. Mike DeWine (R-Ohio), chairman of the Senate Appropriations subcommittee overseeing the District, who a few weeks ago called for the closing of Oak Hill.

In a statement issued last night, Ronald S. Sullivan Jr., the director of the public defender service, said the city needed to finally live up to its agreements and its responsibilities. He said the agreement was the "final opportunity" to act.

Uncertainty about the fate of Youth Services has complicated the search for a permanent administrator for the agency. Bobb said yesterday's agreement will remove that as an obstacle.

The city has formally extended an offer to Leonard Dixon, a nationally known juvenile justice expert from Detroit. Dixon is executive director of the Wayne County Juvenile Detention Facility, a 194-bed juvenile center in Detroit, and is considering the offer, Bobb said.

Staff researcher Bobbye Pratt contributed to this report.