MANAGUA, Nicaragua — Daniel Ortega was a young, victorious revolutionary in olive fatigues and oversize glasses when Jimmy Carter welcomed him to the White House in 1979 and asked him to “be kinder” to the United States.

To Ronald Reagan, Ortega was a dangerous Marxist — a “little dictator” backed by the Soviet Union — and a starring player in the 1980s Cold War drama when the United States fought communism in its backyard. During the Obama administration, Ortega was seen as an aging, but not entirely benign, leftist who had warmed to capitalism and kept gang violence at bay.

Now 72 and in his fourth term as president, Ortega has lost the fatigues and glasses. His hair has thinned, and he speaks just above a whisper. And yet to many, this incarnation of Ortega is the most dangerous of all.

Over the past four months, he has waged a merciless and bloody attack against protesters who want him to resign, prompting many to liken the former guerrilla commander to the dictatorship that he helped overthrow nearly 40 years ago. The United States has responded with condemnations, sanctions against his inner circle and a push for early elections.

Ortega has refused to step down and blames the unrest on his old foe.

“The United States has always had its eye on us,” he told CNN last month.

While many in Nicaragua were shocked by the swift escalation of violence, the warning signs started long ago. Throughout his political career, Ortega has spurned democracy time and again, preferring to seize every opportunity for his Sandinista party to secure perpetual rule through fraud at the ballot box, institutions stacked with supporters, and changes to the constitution.

“The Ortega of today is not recognizable to anyone who knew him,” said Henry Ruiz, one of Ortega’s fellow guerrillas and a former cabinet member.

Ortega rules Nicaragua with a small group of family and loyalists. He made his wife, Rosario Murillo, his vice president. Together they fostered an image on billboards and government broadcasts as beneficent parents of the nation. Their Sandinista party, which began as a guerrilla group in the 1960s, has become a stand-in for the state: At a border crossing into Costa Rica, black-and-red Sandinista banners fly, but not the blue-and-white flag of Nicaragua.

As his family has grown wealthier and more powerful — amassing land and strategic businesses in media, energy and more — these anti-democratic tendencies have grown more pronounced.

In the most recent crisis, police and masked gunmen working with them have hunted down opposition leaders and protesters by the hundreds. Many have been killed, arrested or disappeared. Thousands have fled south to Costa Rica.

Ortega has blamed the unrest on coup plotters backed by the United States. He has some experience in this area: In the 1980s, the CIA secretly created a rebel army, known as the contras, to try to overthrow his government.

He now claims he has neutralized the threat against him and regained control over all cities, and he has rejected early elections. He seems intent on weathering the storm, saying he will not step down before the next election, in 2021.

A pro-government caravan drives through Diriamba, Nicaragua, in support of President Daniel Ortega and his Sandinista National Liberation Front or FSLN. (Joshua Partlow/The Washington Post)

Nicaragua’s ambassador to Washington offered an interview with Ortega, then retracted it. Several other members of his government and family did not respond to emails and phone calls seeking comment.

Many observers, including his former Sandinista comrades, believe his days as Nicaragua’s leader are numbered.

“When an animal has been shot in the leg, he runs and runs and runs, but he has to fall,” said Sergio Ramírez, a famous Nicaraguan novelist who served under Ortega as vice president in the 1980s. “I think Ortega has taken a leg shot. The world that he created is collapsing very quickly.”

1974-1990: A Marxist ideologue changed by prison

Daniel Ortega was never the most charismatic Sandinista leader. He was not a great military strategist; his younger brother, Humberto, who went on to become defense minister, was known for that. Nor was he the most zealous Marxist ideologue among his comrades. He had a reputation as a pragmatic ­consensus-builder.

Ortega grew up in a working-class neighborhood in the capital, the son of a man who fought against the U.S. Marine Corps and instilled in him a strong anti-imperialist streak. While a teen, he joined the resistance against the dictatorship of Anastasio Somoza Debayle, whose family had ruled Nicaragua for decades.

After robbing banks to fund the revolution, Ortega spent much of his 20s in prison, where he endured torture and abuse. The man who emerged in 1974 was terse, withdrawn and distrustful, according to people who knew him then.

“It seems this period influenced his personality a lot,” said Ramírez, the novelist. “He has always been a very isolated man. Not someone with a lot of friends.”

Once the Sandinistas overthrew the government in 1979, Ortega maneuvered his way into the ruling junta and won the presidency in 1984. He emerged as a leader in part because he was seen as someone who wouldn’t impose his will on the others.

“He was not going to put anybody in his shadow,” Ramírez said.

Many opponents found the Sandinistas undemocratic, as the government censored the media, stacked the electoral council and used control over ration cards to encourage loyalty to the party.

Then, as now, Ortega had a reputation as a hands-off leader, a man interested in outmaneuvering rivals but who delegated often. These days, his wife, Murillo, often runs meetings with cabinet ministers and speaks on behalf of the government.

“He was never someone who governs,” said Mónica Baltodano, a former guerrilla who fought alongside Ortega and is a historian of the Sandinistas. “He traveled a lot in the countryside. And part of the strength of his leadership rests in those years and the links he developed with the Sandinista masses and the people in general.”

During his first term, Ortega also had to contend with a U.S.-
organized war against him. The contras, who blew up bridges and mined Nicaraguan harbors, fought the Sandinistas for years in a conflict that killed tens of thousands.

“The United States government is sponsoring a campaign of death aimed against Nicaragua,” Ortega said at a rally before the 1984 election, according to Stephen Kinzer’s history of Nicaragua, “Blood of Brothers.” “They say we’re anti-democratic, but we know what real democracy means. Democracy is literacy, democracy is land reform, democracy is education and public health.”

After one term, a war-weary nation voted Ortega out of power in 1990.

2006-2018: Ortega returns and consolidates power

The Ortega who recaptured the presidency in 2006 — after losing three straight elections — had dropped the Marxism, toned down the anti-Americanism and amped up his talk of peace and Christian values. He reached out to the private sector and cultivated foreign investment. Hundreds of millions of dollars in cheap Venezuelan oil provided by Hugo Chávez’s government padded the budget and boosted social programs.

Nicaragua, which remains the second-poorest country in the hemisphere, after Haiti, went on to average more than 4 percent annual GDP growth over the next 10 years.

“It was a very pleasant surprise to me that he went about managing the economy in a way that I would have done it,” said Francisco Aguirre Sacasa, who was Nicaragua’s foreign minister in a ­period before Ortega retook the presidency. “But what we did also notice is that he was tightening his control on the National Assembly, he was tightening his control on the judicial power, and right at the very top the Supreme Court. He had completely taken control of the electoral power at that point.”

There were persistent accusations of fraud on behalf of Ortega’s supporters in the 2006 vote and the ones after that. When he won in 2011, the European Union’s electoral mission said the vote was “opaque and arbitrary.” Before the 2016 vote, Ortega’s allies in the legislature changed the constitution, eliminating term limits and forcing lawmakers to vote along party lines.

The Supreme Court also blocked a leading opposition candidate, Eduardo Montealegre, from participating in the election, and the Supreme Electoral Council forced 16 opposition lawmakers from their seats. Ortega refused to allow independent election observers into Nicaragua.

The protests that broke out in April were remarkable in part because dissent had been so effectively muzzled in Nicaragua for years. Even small demonstrations, such as those over Ortega’s plan to build a canal across the country with Chinese financing, were met with swift repression and sometimes violence.

“It surprised me how quickly this exploded,” said Montealegre, a former foreign minister and finance minister. “But knowing all we have gone through, there was an enormous built-up dissatisfaction.”

In April, police and pro-government militias used tear gas, rubber bullets and live rounds to subdue the crowds. As the death toll mounted, Ortega agreed to a dialogue process, mediated by the Catholic Church, to hear from protesters, business executives and civil society leaders.

Early on in the crisis, Ortega expressed a willingness to consider early elections, according to two senior U.S. officials. But he ultimately chose not to pursue that path with negotiators, and talks with the church broke down.

Those who oppose Ortega are viewed as enemies of the state.

If you are against the government, “they either want you out of the country, jailed or dead,” said a senior U.S. official. “They’ve been actively working on this.”

Ortega’s former Sandinista allies talk about splits within upper levels of his government and about aides who remain loyal only out of fear.

“For a majority of people, he is an assassin, he is a criminal, he is a torturer,” said Baltodano, the Sandinista historian and former Ortega ally. “He’s already been defeated strategically.”

Ismael Lopez Ocampo contributed to this report.