A D.C. Superior Court judge ordered wide-ranging improvements yesterday in the District's provision of shelter for homeless families, requiring that within 90 days the city move families from run-down welfare hotels to "apartment-style housing" with kitchens and bathrooms.

The preliminary injunction, issued by Judge Richard A. Levie, came less than four weeks before a scheduled referendum on the D.C. Council's attempt to limit its responsibility for the homeless. Levie, in remarks near the end of his 73-page decision, suggested his order "will still be appropriate" no matter what the result of the Nov. 6 referendum.

Levie's was the latest in a long string of judicial findings that the city is not meeting the minimum legal standard of services to needy populations. Other judges have made similar rulings on behalf of juvenile detainees, the mentally retarded, adult prisoners and homeless people. In each case, the city has been held in violation of its own laws or of legally binding agreements made in court.

Different laws govern the city's obligation to shelter homeless individuals and homeless families. But both laws -- a 1984 statute for individuals and a 1987 statute for families -- have been the subject of extensive recent debate, with officials and some D.C. Council members asserting that the city can no longer afford an open-ended commitment to the homeless.

In March, as the case decided yesterday was coming to trial, the council voted to cut $19 million, or more than half, from the city's budget for services to the homeless. In June and July, the council amended both its laws on the homeless to say that no homeless person or family has an entitlement, or enforceable right, to emergency shelter or services.

Activists for the homeless, vowing to reverse the amendments, gathered enough signatures to force a referendum on the issue. Voters will decide the question, Referendum 5, in the general election next month.

In yesterday's order, Levie rejected a motion by the city to await the results of the referendum before ruling on the case. He also rejected requests by the city to dismiss the case and to permit the introduction of additional evidence. Because Levie for the first time certified the case as a "class action," all homeless families -- not just the individual families who sued -- will benefit from yesterday's decision.

"We're going to do everything we can to live with it, but I do also think this order may be the subject of an appeal," said Claude E. Bailey, a spokesman for the D.C. corporation counsel.

Stephen J. Harburg, one of a team of plaintiffs' lawyers, hailed the ruling as "a major victory." Advocates for the homeless say there are 500 to 600 homeless families in the city's emergency shelter system, including about 200 in "horrendous" welfare hotels.

"Seventy-five percent of their budget has gone toward funding families to go to hotels to the tune of $3,000 per month per family, which is a blatant mismanagement of the program," said Susan Sinclair-Smith, director of the Washington Legal Clinic for the Homeless.

Though the city has closed the two best-known hotels, the Capitol City Inn and the Pitts Hotel, it continues to use the Budget Motor Inn on New York Avenue NE and the Braxton Motel and the General Scott Inn on Rhode Island Avenue NW.

The hotels have no cooking facilities and generally forbid residents to bring food into rooms, requiring three bus trips a day for meals at the Mount Zion Baptist Church at Sixth and N streets NW.

"You virtually have your hands tied," Sinclair-Smith said. "You have to spend most of your time catching a bus for meals rather than looking for housing or applying for a job."