Inside the Polytechnic University of Nicaragua in Managua, which has become a stronghold for protesters, a woman lights candles at a makeshift memorial for students who have been killed in recent unrest. (Joshua Partlow/For The Washington Post)

Every day now, flag-waving crowds taunt a man who has ruled them for more than a decade, a man who does not allow protests.

Daniel Ortega, a 72-year-old Marxist guerrilla famed for his Cold War duels with Washington, held near total power in recent years, decorating the capital with billboards in his honor. Now protesters march down streets tagged with fresh graffiti reading “Get out Ortega” and “Death to Daniel.”

The most momentous upheaval in this Central American country in nearly 40 years is underway, a change that is shaking one of the last towering figures from a generation of Latin American leftist revolutionaries who became rulers. The Castros no longer hold the presidency of Cuba; Venezuelan leader Hugo Chávez has died; and now, in Nicaragua, Ortega and his Sandinista movement could be facing the end of their era.

“There is a dictatorship in this country, and we want freedom,” said Diana Lopez, a 26-year-old piano teacher who stood in a swirl of waving Nicaraguan flags in a traffic circle at a protest on Wednesday night.

After several terrifying days of violence and mass unrest that left at least 38 people dead, the uprising in Nicaragua has entered a calmer but potentially more significant phase, with pro-democracy protesters allowed to march and a group of students, business leaders and Catholic clergy preparing to negotiate with Ortega to roll back the repressive measures of recent years.

The nationwide outburst has become the biggest challenge ever to Ortega, who led a 1979 revolution against a right-wing dictator and a subsequent war against U.S.-backed rebels, and is now in his third consecutive term as president.

“The people lost their fear,” said Mykel Monterrey, a Catholic priest who lives next to a university that students have occupied and patrol with slingshots, homemade mortar tubes and metal rods. “They are no longer afraid to express themselves.”

The uprising was sparked by a seemingly pedestrian issue, an overhaul of the social security system. As word of the protests spread across social networks and cellphones, Ortega’s government sought to punish the demonstrators pouring into the streets. Chaotic scenes broke out as police fired into crowds in downtown Managua. Masked gunmen apparently affiliated with the government set fire to a dissident radio station. Police and assailants entered the Metropolitan Cathedral grounds and fired on hundreds of students huddled inside. The government blocked independent news channels from broadcasting, and reporters for state-run media resigned on air. Widespread looting broke out.

And then the government blinked.

On Sunday, Ortega called off the social security overhaul. By Tuesday, many students who had been taken prisoner were freed — some barefoot and bruised, their heads shaved, telling stories of beatings and torn-out fingernails. Police and their allies — white T-shirted pro-government Sandinista Youth and the motorcycle-riding “turbas” — seemed to melt away, allowing protests to proceed unchallenged. Ortega has said he is willing to have dialogue.

Many who lived through the chaos feel they have crossed a threshold.

“We got hit by a lightning bolt,” said Anibal Toruño, director of Radio Dario in the country’s ­second-largest city, Leon. The station was torched on Friday but is now broadcasting clandestinely. “Nicaragua will never be the same.”

The storm had been brewing for a long time.

Ortega and his fellow Sandinista guerrillas overthrew the U.S.-backed dictatorship of Anastasio Somoza in 1979, and he led Nicaragua until 1990. He recaptured the presidency in 2006.

Ortega had moderated some of his views over the years, becoming more business-minded and open to foreign investment. His security apparatus prevented the type of rampant crime and gang violence that have devastated neighboring Honduras and El Salvador. In recent years, the economy grew and government spending for the poor boosted his popularity.

But as he consolidated power, authoritarian tendencies became more pronounced. The congress and Supreme Electoral Council are widely seen as loyal to him. Changes to the constitution in 2014 eliminated term limits. He won the past two elections amid accusations of fraud. The Supreme Court blocked a leading opposition candidate from participating in the 2016 election.

Ortega, his wife, Rosario Murillo — who is vice president — and their relatives have faced accusations of enriching themselves with government funds. His relationship with the business community has soured as more decisions get made essentially by decree.

The world has changed around Ortega, as well. Once buoyed by Venezuelan petrodollars, Nicaragua can no longer count on that lifeline as Venezuela’s economy has collapsed.

Students became enraged earlier this month at the government’s slow response to a forest fire in Indio Maiz, a biological reserve in southeastern Nicaragua. The subsequent decision to change the social security system, requiring workers to pay more and receive less upon ­retirement, added fuel to the discontent.

“The break was really with the social security,” said José Adán Aguerri, president of Cosep, the country’s main business organization, which organized one of the biggest protest marches and has called for dialogue. “What’s happening now is a situation that nobody saw coming — the way that the security forces were used and the amount of lives lost.”

The White House said in a statement Tuesday that “the repugnant political violence by police and pro-government thugs against the people of Nicaragua” has “shocked the democratic international community.”

Nicaraguans were shocked by the government’s harsh reaction to the demonstrations. On April 18, for example, pensioners in the town of Leon who were protesting the social security changes were roughed up by authorities, images that spread on the news and social media.

On Friday evening, Toruño and several members of his radio station staff were in their studio in Leon when truckloads of masked men carrying AK-47s and sacks of explosives burst through the front door and doused the office with gasoline, according to several people who were there. When the men fired into the gas, a fireball engulfed at least two of the attackers, who later died, the witnesses said.

As the building burned, neighbors broke down the doors and helped the staff escape largely unscathed.

“The plan was to kill us all,” Toruño said.

Among those killed in the demonstrations was Moroni Lopez, a 22-year-old English student and former Mormon missionary. He had joined the protests after watching footage of police roughing up protesters.

“He saw this video on the news and he said, ‘Look what they are doing to the elderly,’ ” his mother, Alba Garcia Vargas, recalled. “He was so enraged that he went to help.”

Lopez lived in Ciudad Sandino, an area on the outskirts of Managua renamed after the Sandinista revolutionaries came to power.

“Let’s get going,” Lopez texted his neighbor and friend, Erick Espinoza, on Thursday, urging him to join the protest.

“Loco,” replied Espinoza, 20, “we’re a minority here” — reflecting his worries that the Sandinista Youth would crack down.

“It doesn’t matter,” Lopez wrote. “More will join us.”

In cellphone videos taken of a large protest on Friday, Lopez can be seen walking with a large crowd in Managua chanting “Daniel! Somoza! You are the same thing.”

After the protest march came under fire from police, Lopez joined protesters in a human chain that passed bricks to a group of students who had barricaded themselves near the National Engineering University. At some point in the melee, a bullet struck him and pierced his lung, according to his death certificate. His mother learned of his death when a woman who had been standing next to Lopez called her, using his cellphone.

“He wanted to help out as a volunteer,” said his father, Jose Gabriel Lopez. “The police surrounded them.”

Ismael Lopez Ocampo and Sarah Kinosian contributed to this report.