A D.C. Superior Court judge ordered major changes yesterday in the District's juvenile detention system, including a cut of more than 50 percent in the number of youths in its three juvenile institutions.

Judge Ricardo Urbina said the city should be able to sharply reduce its incarcerated population by placing more youths in shelter homes, greatly expanding existing foster care facilities and providing better vocational and drug rehabilitation programs.

The city's adult prison system already is operating under a variety of court orders designed to reduce crowding and improve conditions of incarceration.

Urbina gave no specific deadline for meeting his population limit, but he said the city should have no more than 102 youths housed in its three security facilities.

Last month, Youth Services Adminstration officials said 264 juveniles were housed at Oak Hill, Cedar Knoll and the Receiving Home.

Urbina's order stemmed from a 1985 suit, brought by the Public Defender Service and the American Civil Liberties Union's National Prison Project, charging that youth offenders routinely are subjected to unsafe conditions and unnecessary incarceration.

As part of a settlement of the suit, a three-member panel was asked to study the city's juvenile detention practices and produce a plan for Urbina's consideration to improve services.

The suit charged that the juveniles often were beaten, their quarters were unsanitary and vermin-infested, their rights to due process often were violated and they received little or no training and rehabilitation.

In addition to the population limit, the judge ordered:The placement of no more than 60 juveniles in residential treatment facilities outside the city; about 150 youths now are sent to out-of-state facilities as part of their sentence.

The establishment of five "secure" group homes, with 12 beds each, for violent and chronic offenders, including one program for chronic drug abusers and one for chronic drug dealers.

The addition of at least 35 new short-term and long-term foster care spots for juveniles and the creation of new group homes for about 60 juveniles.

Judge Urbina noted in the 19-page order that the city and the plaintiffs in the case agreed that youths should be placed in the "least restrictive setting" and that "greater emphasis" should be put on treatment rather than on incarceration.

City officials declined to comment publicly on the judge's ruling because they had just received it. But other city officials complained privately that the population limit was too severe, and that the institutions were crowded because the judges were ordering too many youths confined in them.

In addition, they worried about the city's ability to provide acceptable placements in the community for such a large number of youths with criminal histories.

The judge ordered the creation of new group homes in the community for about 120 youths. The city has few group homes for juveniles, and faces sharply increased demand for such homes for the mentally ill and others. The city's plans to expand such facilities in neighborhoods such as Georgetown and upper Northwest recently have generated protest from residents.

Lawyers representing the juveniles in the lawsuit, however, applauded the judge's action, calling it "long awaited."

"It is clear that all components of the juvenile justice system are now going to be striving toward one fundamental goal," said public defender Cheryl Long, "and that is that everyone will be expected to exhaust all possibilities of maintaining a child in the community before removing the child to a detention or treatment facility."

Long said the "time had come for the city to concentrate" on complying with the judge's order rather than following a pattern of "making excuses about why it was taking so long to fully comply with the decree."

A monitor, appointed as part of the settlement, and lawyers for the youths have complained regularly that the city is dragging its heels in implementing the settlement.

Jesse E. Williams Jr., director of Youth Services Administration, said last month at a City Council oversight meeting that he could not guarantee that Cedar Knolls would be closed by Dec. 1 as approved in the settlement.