The White House and homeless activist Mitch Snyder yesterday reached an agreement under which Snyder ended a month-long hunger strike and the federal government pledged to turn over the homeless shelter at Second and D streets NW to the District government, along with $5 million to renovate it.

The agreement -- mediated by Capitol Hill staff members -- capped four days of hurried behind-the-scenes negotiations, which sources said White House officials entered into in part because of fear that Snyder would die from his fast. Administration officials also feared political embarrassment over the shelter controversy because they had heard CBS' "60 Minutes" planned a report on Snyder, sources said.

It was the second time Snyder has extracted concessions from the White House by fasting.

Two days before President Reagan's reelection in November 1984, Snyder ended a 51-day fast only after the president promised to turn the 800-bed shelter in an old Federal City College building into a model facility. "60 Minutes" broadcast a report on Snyder the same night in November that that agreement was reached.

But Snyder and the Reagan administration wrangled over how the Northwest Washington building should be renovated, leading to the latest hunger strike.

Yesterday's agreement ended, at least for now, two years of debate about the fate of the rundown shelter.

Just Saturday, Snyder had refused the White House's offer, sticking to his demand of $7.5 million in federal funds to renovate the building. Yesterday, Snyder said that he and fasting coworkers from the Community for Creative Non-Violence "didn't want to fight and die for a million dollars at this point." Snyder began his fast Feb. 12, and has taken only water since then. Supporters said doctors told Snyder last week that his potassium level was dangerously low. About a dozen other CCNV members have been fasting with him, but they have been taking various liquids.

"In this day of hard times and tough struggles, we're willing to start here," a beaming D.C. Mayor Marion Barry said at a news conference at the center, where the agreement was announced. "I'm confident this shelter can be a model shelter."

Barry added that the D.C. government is acting only as a "conduit" in the transaction.

City and White House officials have not agreed on some specifics of the pact, but it calls for the federal government to transfer title of the downtown facility -- valued at $18 million -- to the city for free, and for the city to lease it to CCNV.

Barry, who has been under fire for the crowding crisis in city jails and disclosure about payments from a city contractor to one of his deputy mayors, was upbeat yesterday. He broke bread with Snyder in Snyder's first meal in 33 days.

But other local officials and activists for the homeless were critical of the shelter plan.

D.C. Del. Walter Fauntroy said yesterday he is "disappointed" by the deal because it does not provide for health, mental health and job programs for the homeless persons who stay at the shelter each night, adding that he disapproves of such "warehousing" of individuals.

Snyder said CCNV will provide drug and alcohol rehabilitation programs, a medical infirmary and job counseling service, among other projects, using volunteer help and private donations.

Some local officials are skeptical about whether that can be accomplished, and they say that they fear the District government will end up footing a large bill to provide programs and services to the shelter's homeless.

"There's no question," said City Council member Polly Shackleton (D-Ward 3), whose Human Services Committee oversees expenditures for the homeless. "Somebody's going to come up with some money to have programs, and I assume it would be the city . . . . More money will be needed to run the place properly."

The status of the shelter -- described by critics as an uninhabitable firetrap -- has been unclear since President Reagan agreed in late December to call off a plan to forcibly evict the hundreds of homeless residents and allowed the building to stay open through the winter. The city recently paid for $250,000 in emergency roof and fire code repairs.

With the shelter scheduled to be shut down, Snyder said earlier this year that he would rely on publicity surrounding a movie being made about his life to bring pressure on public officials to keep the center operating past this spring.

White House officials started the negotiating late last week as Snyder's health apparently worsened, and in response to reports that "60 Minutes" was planning to run its Snyder piece yesterday. "60 Minutes" did not air the story on Snyder last night.

By yesterday, Snyder had lost about 47 pounds and looked pale and drawn as he spoke to reporters.

Most of the negotiating was conducted by Dennis Thomas, deputy to White House chief of staff Donald T. Regan, and D.C. City Administrator Thomas Downs.

Several congressional offices played a role. On Friday, White House officials called Sen. Charles McC. Mathias Jr. (R-Md.) in Oslo to ask his help in "working out an arrangement," said Mathias spokesman Ann Pincus.

Mathias, chairman of a Senate subcommittee overseeing the District, was in Norway attending a meeting of an organization affiliated with NATO, she said.

Another legislator who helped mediate was Sen. Mark Andrews (R-N.D.), who first became interested in the local homeless issue last December because he disagreed with federal officials' plan to storm the shelter a few days after Christmas.

Communicating with White House officials through intermediaries, Snyder said he needed $7.5 million to renovate the building.

City officials negotiated a $6 million compromise offer several days ago, but on Saturday night federal officials reduced the offer to $5 million. Snyder originally rejected the $5 million offer, but yesterday morning he agreed to it, saying he would make up the difference through donations.

The needed renovation includes an almost total gutting of the building, repairs to its aged plumbing, heating and ventilation systems, and subdividing dormitories.