LA PAZ — Bolivia's leftist leader Evo Morales was on track to win a fraught presidential race outright, edging to a decisive 10-point lead over his main rival after accusing the opposition on Wednesday of attempting a "coup" against him.
Delays during the count following Sunday's election, and a sudden shift in fortunes in Morales favor fanned tensions, resulting in protests and marches in the main cities of one of South America's poorest countries.
On Wednesday evening, with the counting almost done, hundreds of flag-waving opposition supporters kept up their protest outside the electoral building in La Paz, chanting and setting off fireworks.
At around midnight in Bolivia, the official count showed Morales, who has governed landlocked Bolivia for almost 14 years, had 46.77% of the vote with just over 98% of ballots counted - putting him 10 points ahead of main rival Carlos Mesa.
If Morales holds onto that lead he would win outright and avoid a risky second round run-off in a vote that has drawn allegations of fraud.
After all the demonstrations over the past few days, the mood in the plaza outside the electoral building had turned more boisterous than angry, with small bonfires and mostly young people chanting that they did not want to live in a dictatorship.
"Evo has accumulated so much power. Look at everything that has happened, he doesn't want to leave," said Franco Garcia, 21, adding he voted for Mesa, a former president, because he would be easier to topple if needed.
"If we continue with Evo, then something like Venezuela awaits us. He has too much power."
The unrest - already the severest test of Morales' rule since he came to power in 2006 - could spread if the outright victory is confirmed, after monitors, foreign governments and the opposition called on Morales to hold a second round vote.
The tensions began after an official quick vote count was disrupted by a day-long halt starting late on Sunday, when a preliminary count of almost 84% of ballots showed the two main rivals heading to a second round.
The Morning Rundown
Get a head start on the morning's top stories.
Morales, the country's first indigenous leader, struck a defiant tone on Wednesday.
In a fiery speech at the government office in La Paz, Morales criticized recent violence that saw electoral offices torched and skirmishes between protesters and police, blaming it on the right-wing opposition and what he described as their foreign backers.
"I have called this conference to denounce, in front of the Bolivian people and the entire world, that a coup d'etat is in progress. In advance, the right had prepared with international support for a coup," he said.
Morales called on the people to "defend democracy." Later in the day, he sought to shore up backing from the country's military at an event in the region of Cochabamba, a key source of political support.
At an evening news conference, government minister Carlos Romero denounced "violent groups," which he said were seeking to confront police with explosives, adding the government would look to hold responsible those promoting the violence.
Mesa, in a video statement on Wednesday, called for "permanent protests" until a second-round vote was confirmed, and said he would present evidence of electoral fraud.
Protesters have demonstrated in La Paz, Santa Cruz and Potosi, with strikes also called in some cities.
"What's he afraid of?"
Morales, a former union leader for coca farmers, has overseen relative stability and economic growth, but angered many by running for a fourth consecutive term in defiance of term limits and a 2016 referendum that voted against him doing so.
"If he wants to be elected cleanly, he should accept a second-round election. What's he afraid of?" asked Maria Luz Vargas, 65, a newspaper seller in La Paz who had joined the protests.
The official election monitor, the Organization of American States, had called the count into question and cited a "drastic" and inexplicable shift in the vote, which it said hurt voters' confidence in the electoral process.
Antonio Costas, one of the six-member electoral team coordinating the vote, stepped down on Tuesday in protest at the halt to the rapid count, although he told Reuters he had not come under political pressure.
A number of foreign governments, including the United States, Brazil and the European Union, also voiced concerns about the integrity of the vote.
At a meeting on Wednesday, the OAS recommended a second-round vote go ahead even if Morales reached a 10-point lead.
Morales has maintained throughout that when the final vote count was announced, he would obtain a first-round win, helped by strong support in the countryside.
"Our triumph has always been with the votes from the rural areas with the votes of the indigenous movement," he said on Wednesday, adding he would respect the final result.
Follow NBC Latino on Facebook, Twitter and Instagram.