Brazil's efforts to put two decades of military dictatorship behind it and begin a new era of civilian rule in optimism and celebration have been thwarted by the continuing uphill struggle for survival by President-elect Tancredo Neves.

A grim aura of confusion has settled over the new government as the 75-year-old political crusader for civilian rule has undergone three emergency operations in the two weeks since he was due to be sworn in as president.

Neves has come to personify for his countrymen the transition from dictatorship to democracy since his election in January by an electoral college that the Brazilian military thought it controlled. He embodies their hopes for a fast, fresh start in resolving the enormous economic and political problems Brazil faces.

South America's largest country has been on an emotional roller coaster since March 14, when Neves was abruptly hospitalized and underwent surgery for an intestinal inflammation.

The Cabinet that Neves had formed through skillful bargaining and trading with Brazil's competing factions, headed by Vice President Jose Sarney, his running mate in the January elections, was sworn in 12 hours after the operation.

A series of public statements designed to reassure the public that Neves would recover followed, but a second operation on March 20 jolted the country and badly damaged the new government's credibility.

When a photograph of Neves sitting up in his hospital room was shown on television yesterday afternoon, Brazilians wondered aloud if their leader was being "Chernenkoed" by being put on public display in his last days, as was the Soviet leader.

Deep emotion as well as calculation surround the visible effort by government officials to wish Neves back to health.

His death would remove not only an important man, but also a powerful symbol of decency for this society.

In an interview in the presidential palace yesterday afternoon, Sarney voiced a hope that Neves might be sworn in at the weekend.

Last night, as hope apparently dwindled, a senior government official still insisted that Neves would be back at the helm within 10 to 25 days.

"I think he should wait 25 days before coming back," the official said.

"That will give us time to organize a really good celebration. We have been waiting for a party for democracy for 20 years, so I think it is worth waiting a few more days to do it right."

The decision to rush Neves to a better equipped hospital in Sao Paulo early today for a third operation, this time to stop internal bleeding, dashed all lingering optimism and forced the government to put on a show of going about business as usual even as it held its collective breath.

Sarney ordered all Cabinet ministers to stay at work in Brasilia and to hold staff meetings to head off an expected rush by senior politicians to Sao Paulo to be on hand for the moment that, in Sarney's words, would turn "a moment of great celebration into a great tragedy."

There seems to be little fear here that the discredited military establishment that seized control of the country in 1964 to oust a leftist president would use this opportunity to take power again.

This month's return to civilian government capped a 10-year process of negotiations, controlled elections and increasingly menacing public demonstrations against continued military rule here.

It was Neves' ability to use the military's own system to defeat it that earned him a public respect and affection that had not been apparent for most of his 50-year political career.

He got Sarney to bolt from the military-sponsored political party last year and join him on the ticket in the electoral college balloting in January. That move helped Neves roll up a 480-to-180 victory and shame the Army into returning to the barracks on schedule.

But it also contained the seeds of the dilemma that now confronts Brazil's new political system, for Sarney's defection angered his former colleagues in the promilitary party and gained him no support among Neves' outraged allies.

In an hour-long conversation yesterday, Sarney walked a careful line between portraying Neves as a beloved and indispensible leader and arguing that the new government could, at the same time, survive Neves' passing if need be.

Sarney thus stressed both that he holds the full powers of the presidency since Neves has not been sworn in, and that he is not using those powers.

Sarney so far merely has carried out instructions left by Neves before he was hospitalized and has not undertaken any major initiatives of his own.

He also voiced a theme sounded by many Brazilians during these tense moments that reflects a measure of pride about how well things have gone and a masked uncertainty about the future.

"This has provided an opportunity to test our institutions and to prove the political maturity" of the Brazilian public and politicians, Sarney said. "We politicians had to show the public that they are not orphans" now that the military has returned to the barracks.

The deepest concern here seems to be that the factions that Neves carefully balanced in forming the government will shortly be at each other's throats as difficult choices have to be made over austerity measures and the writing of a new constitution.

Sarney, who would remain as president, sought to dispel such concern by saying, "All the politicians are aware of the great hope of the populace" in the new democratic government.