The commission, which is dominated by Mr. Hernández’s allies in the conservative National Party, has behaved erratically since the polls closed on Sunday. It waited almost 10 hours to release the first results, which showed Mr. Nasralla ahead by five percentage points with 58 percent of the polling places counted.
But the count then stalled until Tuesday afternoon and after it resumed, Mr. Hernández steadily closed the gap and eventually overtook Mr. Nasralla. The shift led to allegations that the commission was counting only those polling places where Mr. Hernández had won, and was setting aside for special review the tally sheets from areas where he had lost.
The commission agreed to count the remaining tally sheets under pressure from international observers. In a sign of how widespread distrust of the electoral commission has become, Honduras’s conservative main business group joined the call for a full count.
“At the end, there is a lack of confidence in the commission from all sectors,” said Rodolfo Pastor, a strategist for the left-wing Alliance Against the Dictatorship, Mr. Nasralla’s coalition. “The perception that there was manipulation has been created.”
The opposition has asked the electoral commission to disclose vote databases, and it demanded a recount in three departments where turnout was said to be about 20 percentage points higher than the average elsewhere in the country.
Unless those demands are met, the opposition alliance said, it would not take part in the last stage of the count. “That would endorse fraud,” Mr. Pastor wrote in a text message.
Protesters blocked roads and bridges for a second day on Friday to demand an impartial count. In some places they burned tires, filling the air with thick, black smoke. There was some looting, and security forces clashed with protesters in several places, leading to injuries.
Opposition supporters charged that the violent protesters and looters were infiltrators, deployed to give the government an excuse to use the security forces. Vice President Ricardo Alvarez acknowledged that many of the looters were people “taking advantage of the situation,” not supporters of the opposition.
The political turmoil adds to the problems facing Honduras, where two-thirds of the population lives in poverty. Street gangs and drug traffickers operate freely in parts of the country, and despite a fall in the homicide rate, Honduras is still one of the deadliest countries in the world outside a war zone.
Corruption is endemic: Hondurans marched in the streets for weeks in 2015 to protest the theft of hundreds of millions of dollars from the main public health system. High-ranking police officers linked to the assassination of two antidrug officials were removed but have not been investigated.
The postelection unrest also highlights the intense polarization in Honduras, a political divide that burst to the surface in 2009, when President Manuel Zelaya was ousted in a coup.
Mr. Zelaya’s move to the left, including a growing closeness to Venezuela, had alarmed the country’s political and business elites. At the time, however, they justified the coup by arguing that Mr. Zelaya had been seeking to get around a constitutional ban on re-election.
“There’s an institutional weakness and a matter of political culture,” said Dan Restrepo, who was an adviser on Latin America at the National Security Council during the Obama administration. “I think the coup was a symptom rather than a cause of it.”
“There’s hasn’t been political and national reconciliation within the Honduran political classes,” he added. “We’re seeing another manifestation of that now.”
Protests against Mr. Zelaya’s ouster persisted for months, and he ultimately formed Libre, the main party behind the alliance that is supporting Mr. Nasralla.
Ultimately it was Mr. Hernández, not Mr. Zelaya, who found a way to lift the ban on re-election. Two years ago, five Supreme Court judges, handpicked by Mr. Hernández, ruled that the prohibition was unconstitutional.
Mr. Hernández had been widely expected to win a second term. His iron-fist policies against crime gave many people a sense that security was improving, and his social programs handed out benefits to the poor.
His allies in the media assured favorable coverage during the election campaign, and despite campaign finance restrictions, his ads accounted for almost two-thirds of all campaign publicity, according to a report released this week by election observers from the European Union.
But the election results suggest that many voters did not approve of Mr. Hernández’s growing control over the government.
“There is a manifestation of displeasure from a large sector of society with the manner in which he has governed,” Mr. Restrepo said.