Sandinista leader Daniel Ortega was inaugurated as Nicaragua's president today in a ceremony marked by a surprise visit by Cuban President Fidel Castro.

In a relatively conciliatory inaugural address, Ortega reaffirmed the Sandinistas' public commitment to respect political pluralism and private property. He said the seven-month-old dialogue with the United States represented "a magnificent opportunity" to resolve the two countries' differences, although he condemned at length what he called Washington's policy of aggression against Nicaragua.

Ortega also offered for the first time to grant amnesty to all antigovernment rebels without saying, as he had earlier, that leaders of the guerrillas were ineligible.

In another sign of conciliation, Catholic Bishop Pablo Antonio Vega delivered a low-key invocation. Vega, president of the Nicaraguan Bishops' Conference, has been an outspoken critic of the Sandinistas.

Ortega and Vice President Sergio Ramirez took their oaths in front of the grave of a Sandinista hero in a relatively subdued ceremony. The procedure was accompanied by unusually heavy security, and uniformed soldiers have been stationed throughout the city in the days leading up to the inauguration.

Yesterday, a new, Sandinista-dominated National Assembly was sworn in. The two leaders and the 96 deputies in the legislature are to serve six-year terms following nationwide elections Nov. 4.

The inauguration completed the first phase of the Sandinistas' program for legitimizing their rule, in part for the benefit of international public opinion. The next step will be for the legislature to draw up a constitution, a process that is expected to take two years.

The Sandinista National Liberation Front came to power in July 1979 in a nationwide insurrection that toppled dictator Anastasio Somoza. Until now Ortega had served as chief of state in his capacity as coordinator of the ruling three-man revolutionary junta, while Ramirez was the Sandinistas' other representative on the junta.

Castro's arrival, in his second trip to Nicaragua, added luster to a guest list that otherwise lacked well-known international figures. Castro's trip was considered politically significant because the United States has criticized Nicaragua for its close ties with Cuba.

Castro arrived this morning at Sandino Airport, where he embraced Ortega and greeted a crowd of journalists but declined to answer questions. His previous visit to Nicaragua was in 1980 for the first anniversary of the revolution.

The United States was represented at the ceremony by Ambassador Harry Bergold. The Soviet Union sent a vice president of the Presidium of the Supreme Soviet, Antanas Barkaosaska.

Other foreign officials in attendance included French Education Minister Pierre Chevenement, and the foreign ministers of the four Contadora countries. These nations -- Mexico, Venezuela, Panama and Colombia -- are seeking to negotiate a regional agreement to end fighting in Central America.

Afterward, the crowd chanted "poder popular," which translates roughly as "power to the people." Ortega donned a presidential sash bearing the blue and white of Nicaragua's flag. The sash and the singing of the traditional Nicaraguan national anthem rather than the militant Sandinista anthem at the ceremony appeared designed to deflect criticism that the Sandinista front has imposed its rule on the country at the expense of rival parties.

"We assume these functions as comrade president of all Nicaraguans," Ortega said. In another apparent response to foreign criticisms, Ortega twice asserted that Nicaragua follows a nonaligned foreign policy. Castro's presence, however, was a reminder that the country has significantly warmer relations with the Soviet Bloc than with the United States.

Ortega said the United States has been intervening in Nicaraguan affairs since 1854, when American adventurer William Walker seized power briefly at the head of a private army. Ortega said that the nearly four-year-old war with antigovernment guerrillas, who were organized and financed for a time by the CIA, has cost 7,698 lives.

But he added: "In spite of the situation, Nicaragua is not an enemy of the United States and defends the right to normalize its relations with that nation."