The right-wing coalition that has dominated El Salvador's legislative assembly for almost a year collapsed last night, reopening the question of who is ruling the country just as the government's war with leftist guerrillas has escalated.

Moderate politicians, while strengthened by the disarray in the bloc led by ultrarightist former Army major Roberto D'Aubuisson, said they had received death threats, raising the specter that death-squad violence could reemerge against the rightists' adversaries.

D'Aubuisson's coalition fell apart last night in a showdown over the rightist leader's attempt to block the appointment of a new health minister. In key votes of 39 to 0, with 19 rightist loyalists absent, delegates approved the appointment and established new procedures to weaken D'Aubuisson's power as president of the constituent assembly, which he has controlled since his coalition won a majority in elections last March.

The assembly action follows a mutiny two weeks ago of a Salvadoran battlefield commander that appeared to have reshuffled power in the military high command and undermined the position of the top commander, Defense Minister Jose Guillermo Garcia.

For the moment, the only apparent winner to emerge from the confusion is interim President Alvaro Magana, who was named chief executive in a compromise last year and until now often has been described as a figurehead.

Christian Democratic leader Julio Adolfo Rey Prendes said in a telephone interview this morning that while D'Aubuisson's power has been "weakened considerably," the new majority in the assembly has "not decided whether it is worth the trouble to remove D'Aubuisson from his post" as president of the assembly.

Eight of yesterday's votes against D'Aubuisson belonged to conservative deputies who have voted with him as a bloc on other issues. Other conservatives had defected earlier, and political sources said that even without the eight votes the Christian Democrats had forged a new coalition with a one-vote majority going into last night's session.

During the critical assembly session yesterday, according to Rey Prendes and others in attendance, at least nine deputies received anonymous death threats against themselves or their families and extra units of the National Police were called out to protect the assembly building.

D'Aubuisson, a former military intelligence officer, and his backers have often been accused of association with paramilitary death squads targeting moderates as well as leftist politicians, and there was fear some rightists might resort to violence as they lose ground politically.

D'Aubuisson operated clandestinely for many months and was linked to several coup plots in 1980 against the government. Until he decided to enter the electoral process in the fall of 1981, he and his followers made orderly political activity virtually impossible, labeling even centrist and moderate leftist leaders "communists."

The accusations frequently were followed by assassinations. The killers operated with military precision and, it is often alleged, with military collusion as well.

D'Aubuisson repeatedly has denied any role in directing such death squads, and no one in El Salvador is making public accusations against him now.

"We will have to move forward with prudence," Rey Prendes said.

Until recently, many Salvadoran political analysts considered that the essential dispute inside the government was that between D'Aubuisson and Defense Minister Garcia, who has received extensive public backing by the U.S. Embassy in El Salvador.

Garcia and his high command handpicked Magana, a civilian banker, to serve as president after the March elections when the political parties were unable to present an acceptable candidate, and Magana often was dismissed privately in political and diplomatic circles as a Garcia puppet. But Magana has emerged strengthened--and independent of Garcia--by his adroit handling of the recent upheavals in the officers corps. Magana has longstanding personal ties with a wide variety of senior officers, some going back to high school days.

When Lt. Col. Sigifredo Ochoa, one of El Salvador's best field commanders, staged a six-day mutiny earlier this month and demanded Garcia's ouster, the defense minister's personal authority was virtually destroyed. Top officials say he is now expected to leave his post in a matter of weeks.

Magana, according to Salvadoran military sources, shrewdly avoided putting his own authority as commander in chief to the test until a deal had been worked out in which the insubordinate officers around Ochoa had agreed to comply with his order.

Moreover, although Ochoa was a long-time friend and sometime political ally of D'Aubuisson's, the rebellion appears finally to have worked against the assembly leader.

Rey Prendes cited D'Aubuisson's "posture of introducing political problems into the armed forces" as a major consideration among many of the deputies who voted against him yesterday, especially the bloc of conservatives in what is now being called the Autonomous National Conciliation Party.

As one deputy put it, that group "is most closely related to the existing military structure, the old official party idea, not the Nazi-fascist tendency of ARENA," the Spanish acronym for D'Aubuisson's party.

The issue that led to yesterday's showdown arrayed D'Aubuisson directly against Magana, who has been trying since November to remove the health minister, an ARENA party member.

On Jan. 17, Magana named a civilian member of the more centrist Democratic Action party to fill the post, and D'Aubuisson tried last night to keep the assembly from meeting to ratify the appointment. With the support of the Autonomous Party deputies, the majority opened the session without D'Aubuisson presiding. They voted to change an administrative rule that had given D'Aubuisson's party a veto over any measure its officers refused to sign, then approved Magana's choice as health minister.

The internal disputes came as guerrillas of the Farabundo Marti National Liberation Front have launched their largest offensives in months, including attacks in seven of El Salvador's 14 provinces.