A D.C. ballot initiative guaranteeing overnight shelter for the homeless has been ruled invalid by a D.C. Superior Court judge who said the measure was improperly allowed on the ballot because it would have required the city to spend money.

Voters last fall overwhelmingly approved the measure, known as Initiative 17 and the first in the nation to guarantee "adequate overnight shelter" to the homeless, despite vigorous opposition from the District government.

Judge Annice Wagner, in a 29-page ruling striking down the initiative, said, "By establishing an enforceable right to benefits by those who qualify for the program, the measure forces the government to appropriate the money for it. This is an indirect exercise of the power to appropriate funds, a power not conferred upon the electorate."

Mayor Marion Barry called the ruling "extremely important" and said he was "pleased" with a decision that preserved the "integrity of the budget process."

Representatives of the Board of Elections and Ethics, who permitted the initiative on the 1984 ballot and were defendants in the suit brought by the District government, said they may appeal the decision because of its possible impact on future initiatives that also could require the city to appropriate money.

Mitch Snyder, leader of the activist Community for Creative Non-Violence that sponsored the initiative, called the ruling "silly" and said his group will appeal.

The initiative would have required the District to provide shelter that is "accessible, safe and sanitary and has an atmosphere of reasonable dignity." The District currently provides 753 shelter beds a night. City officials had argued that up to 15,000 homeless people could seek shelter, which would force the city to spend about $60 million to build new shelters.

In her ruling filed Friday, Wagner said she was not arguing with the "salutary purpose of the proposal." Rather, Wagner wrote, her ruling was concerned solely with the kinds of initiatives permitted by law. Voters, she said, could approve initiatives authorizing new programs. But initiatives forcing the government to spend money, she said, are not appropriate.

"Unlimited power to propose laws through initiative was not granted the voters," Wagner wrote.

Some advocates for the homeless who had opposed the referendum said yesterday they gained no solace from Wagner's decision. Initiative 17 had caused a bitter split among people working with the homeless, with some arguing that the measure would create a lack of interest in the private sector or make the District a magnet for the homeless on the East Coast. Others had objected to the confrontational tactics of CCNV.

"I certainly don't think having the thing rescinded is a victory," said the Rev. Thomas Nees, who runs the Community of Hope shelter and is a member of the Mayor's Commission on Homelessness. "My opposition to the initiative was not a philosophical one but a practical one . . . . I still feel our society is doing an abominable job of providing housing for poor people."

Barry said in a written statement that he wants to make clear he remains committed to the policy that every person "who is out of a home should be able to turn to the public and private sectors for assistance." Barry pointed out that in his 1986 budget proposal he had doubled his request for the homeless to $7.125 million.

Barry also said he believes that Wagner's decision still would allow citizens to voice their wishes through the initiative process.

But, he said, the decision "makes clear that a citizen cannot force the government to spend the money that has not been appropriated through the normal budget process."

Snyder argued that the homeless referendum was no different from a mandatory sentencing initiative approved by voters. That referendum imposed a mandatory prison term for certain crimes.

"There is a cost attached to keeping people in jail," said Snyder. The decision, he said, "makes meaningless the whole initiative process in Washington. Initiatives are not meant just to be public opinion polls."

In her ruling, Wagner noted that "most new laws have some fiscal impact." But she said later, the homeless referendum had "no ceiling on the funds which must be expended for this program . . . . "

Wagner referred frequently in her ruling to two recent D.C. Court of Appeals decisions. In one, the court said unemployment compensation was an improper subject for referendum because implementation would require the appropriation of funds, an act reserved for the City Council.