The efforts of El Salvador's right-wing parties to exclude the governing Christian Democrats from power following Sunday's elections collapsed today as all sides agreed to join in formal talks on constructing a government of national unity.

In messages to the five conservative parties that won 60 percent of the vote, the Christian Democrats called for joint talks on building a unified government. Spokesmen for the rightists said they now would be willing to see Christian Democrats holding high Cabinet positions, although they reiterated that the party's ranking member, ruling junta President Jose Napoleon Duarte, must step down.

The rightist effort to exclude the Christian Democrats from power altogether, made in the euphoria of taking 60 percent of Sunday's massive vote, crumbled in the face of strong suggestions that it would have meant both a cutoff of U.S. aid and perhaps a popular revolt led by the Christian Democrats--who have 40 percent of the electorate behind them.

In private talks and public statements, members of the key parties made clear that the United States had played a behind-the-scenes role in fostering the talks now promised by the parties.

U.S. Ambassador Deane Hinton is known to have warned the conservatives that the presence in the government of ex-Army major Roberto D'Aubuisson, head of the far-right Nationalist Republican Alliance (ARENA in its Spanish abbreviation), could drive Congress to cut off all U.S. aid to El Salvador, and that to exclude the Christian Democrats from power altogether would be equally unacceptable to the United States.

Duarte said he had breakfast with Hinton "to discuss in general the situation of the country," and had kept in touch with him. At ARENA headquarters, spokesman Mario Redaelli stressed to reporters that the party had "never even mentioned D'Aubuisson" as a possible head of government. He said ARENA had indicated that the Christian Democrats "should have some of the most important Cabinet posts," although "not 40 percent of the Cabinet. They have some very good people. They've been in the government and they're very experienced."

Pressed for examples, he named Foreign Minister Fidel Chavez Mena as one who would be acceptable "for some high office." Before the elections, when a Christian Democratic majority seemed possible, Chavez Mena had been considered a likely choice to be named president of the transitional government that is to preside over the writing of a new constitution and the organization of presidential elections.

As early as Tuesday, when the right was still trying to exclude the Christian Democrats, a director of the National Reconciliation Party said he was well aware "that U.S. aid is indispensable" and indicated that the party's policies would do nothing to jeopardize that aid. That party holds the balance of power in the upcoming 60-member assembly, with 14 seats. The Christian Democrats have 24 seats and ARENA 19, while two small parties hold three.

Nobody was predicting any quick agreement across the chasm that divides the two sides in trying to form a broad coalition government.

"The bases of our negotiating position are still under discussion," said Manuel Arrias Rivas, the Christian Democrats' party secretary in the capital. The first formal talks, possibly Friday, are to involve presentations by all sides. "Then, if there is a possibility of negotiations, everyone will begin to make offers," he said.

Duarte is to hold office until the new assembly names a provisional president or some kind of governing junta, but there is virtually no chance that he will be part of that. If the rightists who will control the assembly agree on nothing else, they agree that Duarte's head is the price the Christian Democrats must pay for failing to win a majority. He indicated he would accept that.

"I have never sought any position. I will always accept any decision of the party on any matter," he said.

Despite the resemblance of the panorama to a genuinely functioning, untidy and brawling democracy, Duarte was among officials warning strongly today that the process is far from secure.

"The people went to vote and now comes the struggle for power," he told a press conference. Some "extreme rightists," he said, "have forgotten that this election is only a step; this is not the whole thing." He said there is already "inquietude" within the Armed Forces and among 500,000 Christian Democratic supporters over the delay in forming a government. "The Christian Democratic Party is the only force in the country with strength to stop the avalanche," he said.

In a nationally televised speech later, Duarte warned Salvadorans that to tamper with the acts of the current government would be to tamper with the military position. "This government is a pact between the party and the armed forces," he said, "and all the decrees of this government are a product of the agreement between us."

At the press conference, Duarte acknowledged that his life may be in danger as a result of the country's tradition of killing enemies rather than talking: "There is no question that the right believes I'm in the middle and that my life or my elimination in the process would be the best thing they could have. But I will stay here and continue working."

The names of the winning deputies who will form the new assembly are expected to be announced Friday. Today's agreement to open formal talks among the parties renewed hope that the decision on the form of the coming government will not be left to the deputies.

The most persistent proposal under informal discussion continued to involve a three-member junta, but the composition of its membership was under hot debate. ARENA and the Christian Democrats both want two civilians and one military official. "The Army would elect its own person," explained Redaelli of ARENA. "As far as I know we have the agreement" on that of the National Conciliation and the small rightist Democratic Action, he said. The central issue is the names and parties of the two civilians.

Another approach would involve a four-member junta, including three civilians and a military official. Armed forces officials refused to discuss any of these possibilities.

The unofficial tally of Sunday's vote, announced yesterday as final, continued to rise today to a total of nearly 1.5 million people.