The Reagan administration yesterday agreed to renovate the squalid 800-bed shelter for the homeless in downtown Washington run by the Community for Creative Non-Violence, ending a 51-day hunger strike by Mitch Snyder, the group's leader.

Snyder, who had threatened to starve himself to death unless the administration agreed to spend $5 million to repair the shelter, lost more than 60 pounds during his fast.

He was rushed by ambulance to Howard University Hospital at 3 p.m., shortly after a bedside visit by the chairman of a federal task force on the homeless and a telephone call from Health and Human Services Secretary Margaret M. Heckler informing him that President Reagan had personally approved the agreement hours earlier while en route to a campaign stop aboard Air Force One.

According to a statement by Heckler, the administration pledges to turn the decaying, vermin-infested facility into a "model physical shelter structure to house the homeless . . . to be used as long as a critical need exists." But it stopped short of promising Snyder the $5 million he had said was a condition of ending his fast.

Snyder was listed in serious condition last night in the intensive care unit at Howard, where he was being treated for prolonged starvation and dehydration. Hospital officials said they had not yet determined whether the fast, begun Sept. 15, had left him with any serious physical problems. Snyder, 41, suffered permanent eye damage from a 64-day hunger strike two years ago when he was protesting naming a nuclear submarine the Corpus Christi, which means Body of Christ in Latin.

"I feel real good," said Snyder, smiling weakly as he ended his water-only fast by taking tiny sips of vegetable broth while waiting for the ambulance to arrive at CCNV's communal house at 1345 Euclid St. NW. "I'm deeply grateful to God for letting me live to see this and I'm grateful to the president . . . That's a message to a lot of people two days before the election that homeless people count, and that message found its way into the Oval Office."

The agreement was the result of more than six hours of often heated telephone negotiations that began Saturday night and lasted until 4 a.m. yesterday.

On one side were White House chief of staff James A. Baker III, whose wife Susan had helped CCNV obtain the shelter, Heckler and Harvey Vieth, chairman of the Federal Task Force on Food and Shelter, who visited Snyder yesterday. On the other were Snyder and Carol Fennelly, leaders of the CCNV, an advocacy group that operates the mammoth shelter in an abandoned federal building at 425 Second St. NW which it leases for $1 a year.

HHS officials said they thought repairs to the shelter could cost between $2 million and $5 million. "We can't provide a good estimate until we sit down and look at it," said Vieth, who toured the facility Friday with officials from the General Services Administration. "We're more than willing to work with them and I know Mitch and Carol want to do it in as economical a way as possible."

Snyder's hunger strike received international attention and had prompted several congressmen, including House Speaker Thomas P. O'Neill Jr. (D-Mass.), to urge the administration to fix the building.

Vieth, who has worked with Snyder since last winter and several times publicly asked him to end his fast, said administation officials agreed to repair the shelter -- a demand they had for months rejected -- "for humanistic reasons" and not because Snyder's hunger strike had received wide media attention, including a segment broadcast last night on CBS's "60 Minutes."

"If it wasn't a good thing it wouldn't be done," said Vieth.

Presidential spokesman Larry Speakes said Reagan had seen Washington Post stories about Snyder and the activist group he heads and was aware that Snyder was being profiled on "60 Minutes."

Speakes said the president had Baker direct Heckler to "upgrade the facilities" at the shelter to make it a "model."

"The president wants to do something for the homeless," Speakes said.

One of the sticking points in the negotiations, Vieth said, was CCNV's loose style of operating the shelter and Snyder's demand that federal officials fund the establishment of a 25-bed infirmary and sophisticated medical laboratory, which Vieth said could have posed licensing problems.

As part of the agreement, Snyder also dropped his demand that the White House withdraw a controversial report issued by the Department of Housing and Urban Development that he says greatly underestimates the homeless population nationally.

"We had to be politically realistic," Fennelly said.

Shortly before 2:30 p.m. yesterday, as Vieth emerged from a 20-minute meeting with Snyder, more than three dozen members of the CCNV, including nearly a dozen who were also fasting but not in serious condition, gathered on the first floor of the Euclid street house.

Amid an incessant jangle of telephones Fennelly read Heckler's promises that the federal government would construct kitchen and laundry facilities, a first aid station, lockers, consultation rooms and adequate sprinkler system, as CCNV members cheered loudly.

Then she shook hands with Vieth, who addressed the group. "You guys have put me on a fast during the last 48 hours," he said grinning. "The last 48 hours I haven't had time to eat anything, because we've been working around the clock on this one. I thank Mitch and thank God that he stopped his fast."

Fifteeen minutes later, Snyder, looking emaciated and clad in jeans, a beige T-shirt and flip-flop sandals, was carried down from his fourth-floor bedroom and gently deposited in a ripped orange armchair in the dining room.

"I just want you all to know you have done a really fine job in a really difficult situation," said Snyder. Several CCNV members applauded while others wept and knelt to embrace him.

The group then formed a circle, held hands and prayed. One member played the flute, another read from the Bible and then the group broke the fast passing around a cup of red wine, a loaf of homemade bread and soup. Snyder sipped bouillion from a pottery mug as Fennelly urged him not to drink too much.

A crowd of neighbors and TV camera crews gathered as ambulance attendants arrived, placed Snyder on a gurney and carried him down the broken cement steps.

"Was it worth it, Mitch?" one reporter shouted as he was strapped to a stetcher and loaded into the ambulance.

"Sure it was," he said, flashing a thumbs-up sign.