Former Army major Roberto D'Aubuisson, leader of El Salvador's most right-wing party, was elected to a powerful post as head of the new constituent assembly tonight, even as the Army moved to force election of a national president acceptable to the United States.

D'Aubuisson supporters took all four positions of control in the 60-member assembly, but political observers here disagreed strongly on how much power that will eventually give them.

A deputy who supported D'Aubuisson in the voting said the right had won "a consolation prize," because earlier in the day the Army all but ordered squabbling political parties to nominate banker Alvaro Magana to be provisional president. Magana is anathema to the right wing.

Magana surfaced as the result of stiff pressure from a Reagan administration impatient for the five parties in the assembly to form a united government to fight the leftist guerrillas trying to take power. But the rightists, exulting after D'Aubuisson's election, said they will use the power of the assembly leadership to run the country, adding that if they cannot block Magana's presidency, they will try to make it meaningless.

The stage is now set for an open battle over Magana's ascension to the provisional presidency. Everything depends on whether the delicate alliance forged by the Army between the Christian Democrats and the National Conciliation Party will survive accusations already made by D'Aubuisson's Nationalist Republican Alliance that the coalition was imposed on the country by the United States.

Three rightist parties led by D'Aubuisson's party--known as ARENA, its Spanish abbreviation--hold a majority in the 60-seat assembly over the Christian Democratic Party, which emerged with 24 seats. But the U.S. Congress is unlikely to approve aid to a right-wing government, so the three largest parties have been negotiating since the March 28 elections to try to form a national unity coalition including the Christian Democrats. The leftist guerrillas and their political supporters boycotted the election.

So far, the efforts to form a coalition government have been unsuccessful.

On Tuesday, special U.S. envoy Gen. Vernon Walters arrived for a 24-hour visit, meeting with the military high command and with directors of all the parties involved in the negotiations. He brought a letter from Secretary of State Alexander M. Haig Jr. warning that continued disagreement on who should be president would jeopardize the flow of U.S. economic and military aid. John Carbaugh, an aide to Sen. Jesse Helms (R-N.C.), came along to convince the Salvadorans that Congress would indeed cut them off without a cent if the new government were not acceptable.

Afterward, according to some of the politicians involved, the leaders of each party were summoned to separate meetings at military headquarters where they faced a united front of at least two dozen officers representing the chiefs of all the major military branches, the zone commanders and the provincial brigade commanders.

"They said, 'Here are three names. Pick one,' " related a political leader who went to one of the meetings yesterday. Besides Magana, he said, the Army's list included Reynaldo Galindo Pohl, Salvador's former ambassador to the United Nations, who is called "Dr. No" because he has three times in the past 15 years refused military offers of the presidency; and Rene Fortin Magana (no relation to Alvaro Magana), head of the small Democratic Action party and formerly the most widely mentioned presidential possibility.

But Alvaro Magana was clearly the Army's preference, the politician said, and two of the parties agreed to back him: the Christian Democrats and the National Conciliation Party. National Conciliation leaders split with D'Aubuisson over the presidency despite having cooperated with ARENA in the negotiations and remaining allied with it in the constituent assembly.

"It was a palace coup," complained a prominent ARENA supporter.

Under the agreement, the armed forces also reserved the three most important Cabinet posts for people to be named by Magana: the departments of interior, defense and treasury. The vice president's post is still under discussion, but the Army indicated it would like to see current vice president Gen. Jaime Abdul Gutierrez remain.

The Haig letter warned that continued aid would depend on whether the new Salvadoran government retained the social and economic reforms of the past 29 months of Christian Democratic-military government, observed human rights, guaranteed presidential elections in the near future and fully included the Christian Democrats in positions of power. Agreement by the National Conciliation Party to the naming of Magana was thus widely seen as a major victory for the Christian Democrats.

Christian Democratic assembly leader Julio Rey Prendes agreed with that view. The victory of the three rightist parties in the elections, he said, "went a little to their heads. They thought they could run things without taking into account the real forces of the country," meaning the military and popular support for the Christian Democrats.

But the military move caused so much resentment, ARENA leaders said, that they were able to throw out tentative agreements previously made to divide power in the assembly with the Christian Democrats and instead take all four major posts with the National Conciliation Party. Receiving the gavel to roars of applause from the galleries full of ARENA supporters, D'Aubuisson promised to preserve existing social and economic reforms, guarantee human rights and continue the democratic process, giving the United States at least rhetorical support.

The U.S. State Department in a statement noted that D'Aubuisson's election as assembly president "should not be confused with the selection of the provisional government of El Salvador," United Press International reported.

The U.S. Embassy here regards Magana as a capable administrator with close ties to the Army but independent of any party affiliation. ARENA officials see him as entirely too leftist.

They recall that Magana, 57, was an early adviser to former junta member Gen. Arnoldo Adolfo Majano, a reformist officer who was exiled in 1980 after losing a power struggle with the military right wing. One deputy said: "When the Army goes right, Magana goes right. When it goes left, so does Magana." He could be elected as early as Friday, if the Christian Democrat-National Conciliation agreement holds. As chief executive of the provisional government, Magana would preside over the writing of a new consititution and the organization of presidential elections in the near future.