Hailed as a peacemaker by a joyful outpouring of Salvadorans, Pope John Paul II today urged the U.S.-backed government to promote an end to the three-year-old civil war here through "an authentic dialogue" including all groups in the conflict.

The pope's message, delivered at an outdoor mass attended by several hundred thousand faithful under a scorching sun, seemed to put him at variance with the official policy of President Alvaro Magana's provisional government, which is sanctioned and supported by the United States. He accompanied it with a strong condemnation of terrorism from the left, drawing cheers from huge crowds in both instances.

"No one must be excluded from the effort for peace," John Paul said, adding at another point in his sermon: "The love of Christ the Savior does not permit us to close ourselves in the prison of egoism that denies authentic dialogue, ignores the rights of others and classifies them in the category of enemies to be combated."

The pope later arrived in Guatemala City where he was greeted at the airport by Gen. Efrain Rios Montt, the Guatemalan president, who is a member of the California-based evangelical Church of the World.

Rios Montt welcomed the pontiff with a brief and cordial speech as tens of thousands of Guatemalans cheered, Washington Post correspondent Christopher Dickey reported.

John Paul, in his arrival remarks, did not mention the execution Thursday of six alleged guerrillas in Guatemala which provoked a protest from the Vatican.

Salvador's five-part guerrilla coalition, the Farabundo Marti National Liberation Front, and its political counterpart, the Democratic Revolutionary Front, last fall urged an unconditional dialogue designed to lead to negotiations on a new government including rebel leaders. The Reagan administration, followed by Magana, has refused any negotiations on "power-sharing" and insisted that any leftist participation in Salvadoran politics must come through elections.

Reinforcing that point, Magana used the forum of his greetings to the pontiff to announce publicly for the first time that his government plans to speed up the schedule for new elections, promising them by the end of the year. Previously, the elections had been scheduled for March 1984, two years after the last elections boycotted by the rebel movement.

"Activities must be carried out that are necessary for the incorporation of all political sectors into the democratic process, in close relation with the Central Electoral Council, the collaboration of the Organization of American States and the cooperation of friendly countries," Magana said.

In Washington, President Reagan welcomed Magana's announcement, saying, "We know that open, fair, free elections in that country is the political solution we all want."

Reports from Washington have said that the acceleration in the election timetable was urged by the Reagan administration in an effort to smooth the way in Congress for its request to increase military aid to the sagging Salvadoran Army this year by $60 million, up from $26 million accorded by the last Congress. These reports mentioned mid-December for the balloting.

John Paul, responding at a welcoming ceremony at San Salvador's Ilopango airport, applauded the election plan in an addition to his prepared remarks. But, in a second addition, he gave Magana and gathered ministers and diplomats--including U.S. Ambassador Deane R. Hinton--a foretaste of his call for dialogue.

"The peaceful progress of society has to be founded on respect for the rights of all, so all sides will be given the possibility of collaborating in a climate of true democracy and promotion of the common good," he declared.

As if to reinforce his stand, the pontiff later visited San Salvador's main cathedral and prayed before the tomb of Archbishop Oscar Romero. The prelate was slain by a sniper as he said mass in a hospital chapel in March 1980 after becoming a champion of leftist demands for reform.

The killer has never been arrested. But the assassination was linked to death squads aligned with El Salvador's far-right political groups. Former U.S. ambassador Robert White has since linked consituent assembly president Roberto d'Aubuisson to the plot that led to Romero's murder.

Reflecting the honor due his office, d'Aubuisson was first in a receiving line of government officials who shook hands with the pope. John Paul was seen speaking to d'Aubuisson as the cashiered former Army intelligence officer stood before him, but it was not known what was said.

Romero's successor, Archbishop Arturo Rivera y Damas, has taken up the prelate's role as a spokesman for dialogue and respect for human rights. In what was seen as an endorsement of the church's persistent stand here, John Paul last week confirmed Rivera y Damas as head of the Roman Catholic Church in El Salvador. The pope also had called for a "dialogue among brothers" to find a solution to El Salvador's civil war in a letter to the country's bishops in August.

The Magana government, reflecting sensitivity to Romero's role as an opponent of Salvadoran rightists, omitted John Paul's visit to the cathedral from the day's official schedule. Although the pontiff's plans to honor Romero were well known, and printed in the Vatican's schedule, a government spokesman as late as yesterday contended that he did not know whether the cathedral stop was on.

John Paul, after praying at the tomb, saluted Romero as a "celebrated pastor whom the love of God and the service of man led to sacrifice his very life in a violent way while celebrating the sacrifice of pardon and reconcilation."

In a later address to Salvadoran priests, he underlined the dangers facing El Salvador's church in its identification with persistent calls for respect of human rights, often interpreted in the Salvadoran context as an antigovernment or antiright stand.

"Sometimes pastoral charity that must inspire you and the desire to maintain peace and communion require of you the gift of your lives, sacrificed moment after moment in a daily offering, or in the complete sacrifice such as that of several of your brothers," he said.

In addition to Romero, 11 priests have been assassinated here since 1972. Three American nuns and a woman lay worker were murdered in December 1980.

The pontiff also warned Salvadoran priests against allowing their zeal for social reform to lead them away from church doctrine toward "ideologies that, despite their declarations, oppose the dignity of the human person and his just aspirations." This was taken as a clear reference to Marxism, espoused by several of the rebel movement's main leaders.

As he has throughout his Central American tour, John Paul also warned priests against formal participation in civilian government. There are no priests in the Salvadoran government, but a half dozen clerics are known to be living with the guerrillas in rebel-held territory.