The nation's first referendum guaranteeing homeless people the right to overnight shelter was overwhelmingly approved yesterday by District of Columbia voters.

Although the District government and some advocates for the homeless waged a vigorous campaign against the controversial referendum known as Initiative 17, unofficial returns showed the measure receiving 109,080 votes, or 72 percent, with 42,159 votes, or 27 percent opposed.

"We're very pleased," said Stephen O'Neil, a member of the Community for Creative Non-Violence, a nationally known advocacy group that sponsored the initiative. "It's a powerful statement and a clear message to the city that despite their campaigning against it, the majority of voters think shelter is a good thing."

CCNV members and more than 700 residents of the group's downtown Washington shelter ate a victory dinner of sausage, potato salad and greens and watched the returns on a giant screen TV rented for the occasion. Yesterday marked the first time homeless people in the District were permitted to vote.

Disappointed city officials said they planned to ask a Superior Court judge to declare the initiative invalid. Because both sides expected the initiative to pass, a hearing has already been scheduled for Nov. 13. If the court upholds the referendum, it would not become effective for at least 90 days.

"Obviously we're disappointed but homelessness is a very emotional issue and CCNV was very well organized," said Charles Siegel, a spokesman for the D.C. Department of Human Services. "I think it's clearly a statement that we understand but the question is, should it become law? That is what the court will decide."

Providing "adequate overnight shelter" to as many as 15,000 homeless people, city officials have estimated, could cost $65 million, 10 times the amount currently allocated. District officials tried unsuccessfully to knock the initiative off the ballot and printed leaflets urging its defeat, which were distributed at polling places.

But David A. Clarke, chairman of the City Council, which has the power to change the initiative, took a more moderate view of the potential fiscal implications. "It's not as scary as some people said it would be," he said. "We can do it for less and it will give us room to make our own regulations."

Passage of the initiative was the latest in a string of victories for CCNV. On Sunday its leader, Mitch Snyder, ended a widely publicized 51-day hunger strike after the Reagan administration agreed to make substantial renovations that would transform CCNV's squalid 800-bed downtown Washington shelter into a "model physical" facility.

The initiative would require city officials to provide shelter that is "accessible, safe and sanitary and has an atmosphere of reasonable dignity." Persons who enter the District "for the express purpose of obtaining free shelter" would be excluded from coverage, a provision opponents say is unenforceable and possibly unconstitutional.

Supporters of the initiative -- the only referendum question on the District ballot -- printed more than 150,000 sample ballots and brochures, which they said were distributed by more than 400 volunteers at polling places.

The District government spent $5,000 to print more than 50,000 yellow pamphlets and 600 red-and-white posters urging a "No" vote.

Siegel said the anti-initiative literature was not distributed by city employes but by volunteers.

CCNV members said they were angered by what they termed the District's heavy-handed tactics. "We think it's ironic that when the city is raising the taxpayer argument, they're using public funds to print these things," said Mary Ellen Hombs, a CCNV leader.

But Siegel said city officials did not see anything wrong with the action. "We've checked with our lawyers and we don't believe there are any legal or ethical violations involved."

The referendum also caused bitter divisions among advocates for the homeless, some of whom opposed CCNV's tactics. Others argued that passage could cause the District to become a magnet for homeless people on the East Coast.

CCNV members say they do not think passage of the initiative solves the complex problem of homelessness. "The first step is to get people off the streets," said Hombs. "You can't . . . provide social services to people who are living on grates.