MANAGUA, Nicaragua — President Daniel Ortega looked out over a sea of waving flags and clapped to the same songs that first accompanied him to power nearly 40 years ago.

To his left stood his first lady and vice president, Rosario Murillo, and to the right, Victor Tirado, another aging former guerrilla commander.

The pageantry seemed designed to recall the heyday of Ortega's Cuban-backed Sandinista revolution, even as these days many Nicaraguans — including onetime allies — are comparing him to the dictatorial Somoza dynasty he helped overthrow in 1979

Protests in which dozens of people were killed amid a harsh crackdown by police and government-allied civilians have weakened Ortega, one of the few leftist leaders remaining in power in Latin America, forcing him to pull back on social security reforms that sparked the unrest and facing a newly emboldened opposition determined to see him leave office.

"In repressive, criminal brutality, (Ortega) has been equal to the Somozas and is showing signs of surpassing them," said retired Gen. Hugo Torres, who broke with the Sandinista Front more than 20 years ago.

Ortega has consolidated nearly all levers of power in his hands or those of allies. The Supreme Court pushed aside a ban on presidential re-election in 2011 to let him continue in office. Opponents complain a friendly electoral council tilts the scales in his favor.

For many, Ortega's choice of Murillo as his vice president in last year's election suggests dynastic ambitions.

Many would dispute, however, that the Ortega era matches the thuggish corruption under Anastasio Somoza, who dissolved congress, imprisoned and tortured opponents — Ortega included — and came to own vast tracts of the country.

While tensions have calmed somewhat in recent days, large anti-government demonstrations have continued.

Many expect Ortega, 72, to draw on years of crafty political experience to buy time through an upcoming dialogue mediated by the Catholic Church. Some opponents have already said they will not participate but instead call for a referendum on removing him from power.

This week's rally presided over by Ortega gathered thousands of government loyalists and state workers at Managua's Plaza of Victories and was billed as a call for peace and dialogue.

But even as the crowd observed a moment of silence for those who died in the protests, a little over a mile away Sandinista Youth dismantled a memorial to the victims that had sprung up in a traffic circle.

And the president struck a combative tone, peppering his words with battle references and vowing not to take a single step backward.

"Unfortunately the same people who incited the war before are inciting violence once again," Ortega said. "Once again the sowers of hate have made a deep wound in the heart of the country."

Torres said that was a reference to the dissident Sandinista Renovation Movement, which was founded by breakaway Sandinistas over 20 years ago and of which he is a member.

Some of the dead were children of Sandinistas raised on principles they now accuse Ortega of abandoning.

Victor Cuadras, a 25-year-old chemical engineering student and spokesman for the April 19 University Movement, said he used to belong to Ortega's Sandinista Front and his grandfather died fighting for the Sandinistas in 1978. Standing in front of his shuttered university, he said the only way out of the current crisis is for Ortega to leave power.

"We don't want this dictator anymore, who keeps oppressing us, who keeps persecuting us and with whom we will never have a free Nicaragua," Cuadras said.

Ortega led Nicaragua from 1979 until 1990, fending off a U.S.-sponsored armed rebellion until he was voted out of office. He regained the presidency 11 years ago and has built bridges to former foes in the business community and Catholic Church.

At least until recently, he has been generally popular, presiding over a country with above-average rates of economic growth and anti-poverty programs praised by the World Bank.

"It's the only government that has worried about the poor," said Ada Lopez, a 48-year-old lawyer who attended Monday's pro-government rally.

But lately there have been signs of discontent amid growing reports of government corruption and favored treatment of Ortega's family members.

The government was criticized for its response to wildfires that burned 13,500 acres in a tropical nature reserve last month, sparking some protests that in hindsight seem a precursor to the more recent demonstrations.

The smoldering resentment became a conflagration in mid-April when Ortega decreed changes to prop up the country's troubled social security system that would have raised citizen contributions while reducing benefits.

"What he (Ortega) didn't count on was that the public was actually more open to voice opposition to him and his wife," said Manuel Orozco, a senior associate at The Inter-American Dialogue in Washington. "That was a big, unpleasant surprise for him. He thought that he could contain any type of dissidence with the mobs, but it turned out that wasn't the case."

Relatively small protests by elderly pensioners began April 18 in Managua, the capital, and in Leon. After the protesters were attacked by Sandinista youth groups, university students — historically, a bastion of Sandinista support — reacted in great numbers.

Suddenly marchers carried signs with slogans such as "Daniel and Somoza are the same thing."

Protests spread to other cities, authorities yanked independent news channels covering the unrest off the air, and Murillo accused unspecified political interests of manipulating the demonstrators for shadowy purposes. In some cases polices fired live rounds on protesters, and the non-governmental Permanent Commission on Human Rights says the death toll ultimately reached 63.

Dr. Carlos Jarquin, a medical school professor who was a high-ranking health official in Ortega's first government during the 1980s, found himself volunteering to treat the wounded at a clinic.

"I couldn't sit at home seeing that they were shooting them, that they were torturing them, that they were killing them, and not do anything for them," said Jarquin, who still considers himself a Sandinista. "The current government has abandoned the Sandinista principles of work, of giving to the poor and the repressed."

As the violent clashes continued and international pressure mounted, Ortega announced he would repeal the social security decree and released jailed protesters. The Catholic Church agreed to mediate talks.

Even many allies believed the crackdown had gone too far.

"My reaction was to be extremely worried about the trend of violence that again bloodied the Nicaraguan people's youth — exactly what we had fought against," said Jaime Wheelock, who along with Ortega and Tirado was among the nine commanders of the Nicaraguan revolution.

Wheelock said anguished Sandinista friends had called and pleaded with him to talk to Ortega, and in late April he sent a letter saying protesters had been unjustly attacked and disputing claims that they were part of an "opposition faction.

The crisis indicates that alliances with the private sector and the Catholic Church that Ortega has relied on since returning to power are fraying.

"For the first time, it's the government that is calling for dialogue in a moment in which it finds itself very weakened and in a situation with a very large lack of credibility," said Silvio Baez, Managua's auxiliary bishop, who will participate in the dialogue. "We hope it is a dialogue to change things, not to buy time."