Erratic behavior by the electoral commission since the polls closed has lent credibility to the opposition’s allegations of fraud. The commission, which is controlled by allies of Mr. Hernández, suspended the counting of ballots early Monday after Mr. Nasralla pulled ahead by almost five percentage points.
Counting resumed a day and a half later, on Tuesday afternoon, and the gap steadily began to close. After Mr. Nasralla signed the O.A.S. agreement, the commission’s computer went dark again. The commission’s president said the server was overloaded.
“We don’t recognize the results of the cheating” electoral commission, Mr. Nasralla, 64, said at a news conference as supporters cheered. Holding up what he said were copies of unsigned tally sheets, Mr. Nasralla, a former sportscaster, said, “They are taking us for fools, and they want to steal our victory.”
Mr. Nasralla’s early lead in the election was a surprise. As president, the conservative Mr. Hernández, 49, had established control over all the branches of government, including the electoral commission. His handpicked Supreme Court lifted the Constitution’s ironclad presidential term limit, and his allies in the media assured largely favorable coverage.
This week’s political unrest comes as Honduras grapples with stubbornly high poverty, drug gangs and one of the world’s worst murder rates.
Mr. Hernández had built-in advantages going into the election, with the line blurred between benefits offered by government social programs and his National Party. And despite limits on campaign spending, a report by monitors from the European Union found that the president accounted for almost two-thirds of political advertising spending.
As the night wore on Wednesday, the police used tear gas to disperse demonstrators who gathered outside the building where the ballots are kept.
Members of the opposition said that the long pause in the vote count, followed by the erosion of Mr. Nasralla’s lead, confirmed their suspicions that the commission was trying to rig the election.
International organizations called for it to speed up the count.
“We believe that a faster process, with transparency in the transmission of the results, is a process that does not leave empty spaces, doubts, uncertainties,” said Marisa Matias, the leader of the European Union observer mission.
In Washington, a State Department spokeswoman, Heather Nauert, urged members of the commission “to complete their work without undue delay.”