The United States has threatened to cut off all military and economic aid to El Salvador in order to forestall a rightist coup that has been considered imminent for several days.

One after another, wealthy and middle-class Salvadorans yesterday made their way into the heavily fortified U.S. Embassy to be told unequivocally that the United States opposed the overthrow of the current civilian-military junta.

Embassy officials here declined to elaborate on the exact nature of the pressure that would be brought to bear on El Salvador in the event of a rightist takeover. But a senior State Department official in Washington said today that the country could lose $50 million in economic aid and $5 million to $10 million in military aid planned for the year ending Sept. 30.

The U.S. commitment to the current junta was seen as a last-ditch effort to avoid a major bloodbath in this violatile little country at the heart of Central America.

But the prospects for that effort to succeed fade rapidly each day as the current junta demonstrates lack of ability or will to implement major reforms or control violent confrontations between forces of the extreme left and right. oSo far the junta has become, in effect, a caretaker government that waits as extremist groups consolidate their powers to seize control or mount a full-scale insurrection.

In Washington, the State Department official said that Salvadoran military leaders, landowners and businessmen had been warned explicitly that the United States would cut off both military and economic aid in the event of a coup.

"Any government without civilians, not committed to reforms, and which violated human rights, we would not only refuse to support -- we would oppose," he said.

Said one source in San Salvador close to the civilian members of the junta, "The specter of civil war and possibly the support of the United States is all that maintains this government. It has very little viability, but the alternatives in this crisis are all of such tragic consequences that they are slowing its fall."

Expectations of peace and reform, fostered when relatively liberal younger officers in the military ousted the repressive government of Gen. Carlos Humberto Romero in October, have nearly evaporated.

Yet virtually all of the conflicting political groups -- the military, the Roman Catholic Church, the centurists, leftists and some ultrarightists -- concede the need for basic structural reforms in the economy, society and politics of this country.

The current junta has repeatedly announced plans for fundamental reorganization of the country's economy: massive agrarian reform, the naturalizationn of banking, state control of foreign commerce and respect for human rights.

But the basic divisions in Salvadoran society remain so profound after almost 50 years of dictatorship, and the power of the small, wealthy upper class remains so great, that none of these policies has been implemented.

Such unfulfilled promises have drawn heated attacks from the landed elite and members of the middle class, but they have done little to win over the impoverished majority of the country.

"We have heard promises before," said one farm worker who recently came to the capital to press for agrarian reform. "We don't believe them unitl we can see them, feel them and touch them."

The failure of the government to carry out the economic reforms has been accompanied by a dramatic rise in the level of political violence. Leftist takeovers of government buildings and embassies, strikes and kidnapings have become almost daily occurences. Demonstrations by leftist militants have ended in bloody gunbattles with police forces. Guerrillas and government forces skirmish regularly in the countryside.

Secret rightist groups sometimes identified with elements of the Army and police forces reportedly have continued to kidnap and murder students and workers suspected of being leftist sympathizers or activists.

Local human rights and church groups have counted more than 200 politically motivated deaths since the beginning of the year.

Sources close to the junta say, however, that at least one major reform -- the redistribution of land -- may be on the verge of implementation.

It is against this threat that many observers feel the far right-wing is reacting. In recent days, newly formed rightist groups have stepped up attacks on outspoken, liberal government officials.

A group known as the Broad National Front has repeatedly bought air time on local television stations to denounce certain government officials as members of Marxist guerrilla organizations.

Several of these men, including solicitor for the poor Mario Zamora Rivas, and Jorge Alberto Villacorta, the subsecretary of agriculture have filed a libel suits against the organization and its spokesman, retired Salvadoran Army Maj. Robert D'Aubisson.

Zamora Rivas was murdered early this morning when several armed men later identified as members of the secret Union of White Lawyers broke into his house while he was giving a party. The men took Rivas into the bathroom of his home and shot him.

In this atmosphere of fear and anarchy, the key force in the country at this moment is apparently the army, but the army is seriously divided between advocates of major reform and supporters of a harsher crackdown on the left.

The civilians who participated in the government with the army have also suffered from lack of unity. Those who were brought into the first junta in October were from such a wide range of parties and perspectives -- from conservative supportes of the wealthy to Marxists and socialists -- that they were unable to resolve many of their differences.

But the key problem was the inability of the civilians and the military to reach agreements. The frictions, civilian members of the former government maintain, arose out of evidence that the military was continuing repressive tactics despite promises to support human rights. The military men say they felt that they were doing what was necessary to combat communism.

The dispute between the two groups came to a head on Dec. 26 in what some civilian members of the former coalition now describe as a de facto military coup. Members of the military high command along with commandants of the country's several military garrisons attended a Cabinet meeting and confronted the junta. They denounced the administration and pledged support for Defense Minister Guillermo Garcia in whatever measures he thought power to being peace and order to the country.

The response of all the civilian members of the junta and the Cabinet was to resign.

They were replaced by members of the Christian Democratic Party, which was promised by the military that reforms would indeed by implemented and a dialogue begun with the left. Those promises have not been fulfilled.

"At that moment," said Christian Democratic junta member Hector Dada, "it was possible. But it has been a month and a half. there have been confrontations that the junta has denounced [like the killing of demonstrators on Jan. 22 and the forcible violent ouster of leftists occupying the Christian Democratic headquarters] in which many people were killed."

"They were done to make the dialogue more difficult," said Dada. "They were done by factions in the armed forces that are not in accord with this dialogue . . . Repression in this country is as much (a part of the) social structure as ownership of the land."

Dada said that at the beginning of the year he believed that radical leftist "popular organizations" were disposed to talk with the junta, but not any more. "

These groups, which previously operated as separate entities, have joined forces in the belief that they will soon be able to mount a popular insurrection. At their demonstrations many people can clearly be seen carrying weapons although they generally make an effort to hide them in satchels and packages. Especially in the face of a rightist coup, they no longer talk of compromise.