Thailand’s first election since the 2014 coup was always going to be messy. But it’s turning out to be even more chaotic than many observers expected, setting the stage for renewed tumult after five years of military rule.

Election authorities have faced calls to resign for repeatedly delaying the full results and failing to account for mounting irregularities, including one candidate whose vote totals dropped 80 percent at one point during the count. After the Election Commission finally released some seat totals, it issued a correction about an hour later. It plans to release the vote count on Friday.

Based on the limited information available, allies of exiled tycoon Thaksin Shinawatra were set to win the most seats, followed by the military-backed Palang Pracharath party. Now both of them are racing to win over allies to form a majority in the 500-member lower house of parliament.

An Asian election monitor said Tuesday that the run-up to the vote was “heavily tilted” to benefit the military-backed party and criticized a messy ballot-counting process that created mistrust.

The Bangkok-based Asian Network for Free Elections (ANFREL) stopped short of declaring outright fraud in the election.

“The environment at large is heavily tilted to benefit the military junta,” Amael Vier, an official of the civil society group that seeks to promote democratic elections, told a news briefing. “A lot of people still express distrust towards the electoral process.”

Asked if the election had been free and fair, another ANFREL official declined to comment directly, however.

“So many things have to be considered together,” said its mission head, Rohana Nishanta Hettiarachchie. “It is unfair to conclude that the whole process was free and fair or not.”

Thailand’s Election Commission was not immediately available for comment. It has previously declined to comment on accusations of cheating.

The deck was already stacked in favor of the military, which appoints a 250-strong Senate that can also pick a prime minister — likely to be current junta chief Prayuth Chan-ocha. In theory that means he only needs 126 seats to take power.

But Prayuth has a problem as well. If he takes power without a lower-house majority, Thaksin’s allies could hold a no-confidence vote and boot him out. Then comes another election, or possibly yet another coup — a now routine event that constantly weighs on Southeast Asia’s second-biggest economy.

“If the military can come to terms with the fact that despite all of their efforts they still can’t win, or if there’s a clear resistance, maybe they would stop,” said David Streckfuss, a scholar of Southeast Asian politics and honorary fellow at the University of Wisconsin-Madison. “But I don’t have much hope for that.”

For the military, it wasn’t supposed to be this way. After Prayuth in 2014 deposed a government led by Yingluck Shinawatra, Thaksin’s sister, the ruling junta wrote a new constitution that was designed to finally break the former premier’s lock on Thailand’s electorate.

The army even emulated Thaksin’s populism, which had endeared him over the years to poorer Thais — particularly in the north and northeast — who still laud his policies of cheap health care and guaranteed crop prices. The military’s party proposed lower taxes, a minimum wage increase of more than 30 percent, and price support for rubber, rice, and sugar cane.

In the end they still fell short of winning a democratic mandate, although that doesn’t mean they’ll lose power. The junta has a range of tools to ensure it gets its way, including the backstop of an appointed Senate.

Thaksin ripped the election as “rigged” in a scathing op-ed published in the New York Times. Reeling off a litany of election irregularities, Thaksin warned that the junta may try to buy off smaller parties or disband pro-democracy political parties.

“Whether or not the junta’s leaders now allow the pro-democracy parties to form a government, they will find a way to stay in charge,” Thaksin said. “They have no shame, and they want to be in power no matter what.”

Thaksin has reason to be skeptical. He or his allies have won the most seats in every Thai election over the past two decades, only to see the military or courts oust them. He hasn’t stepped foot in Thailand since he was convicted for corruption in a case brought after the 2006 coup that ousted him. He denies all wrongdoing.

The courts have disbanded three parties linked to him over the years, most recently earlier this month when Thai Raksa Chart was banned for nominating Princess Ubolratana Rajakanya as its prime ministerial candidate. The judges acted soon after King Maha Vajiralongkorn opposed the move, disrupting Thaksin’s election strategy.

Now another party called Future Forward, which opposes military rule and did surprisingly well on Sunday, faces legal challenges after its leader was accused of breaking a draconian computer-crimes law for online commentary critical of the junta.

In the short term it’s unlikely Thailand will see large street protests ahead of the king’s coronation ceremony, which is scheduled for early May. It’s one of the most significant events on the calendar in Thailand, where royals are officially treated as semi-divine.

But after the Election Commission officially certifies results by May 9, anything is possible. A decade ago, demonstrators disrupted a regional summit after a pro-Thaksin party was disbanded — something the military would hope to avoid as it hosts world leaders this year, potentially including U.S. President Donald Trump.

“I don’t think the coalition will last more than two years,” said Punchada Sirivunnabood, an associate professor at Mahidol University, who writes frequently about Thai politics. “It’s the same dividing lines taking a new form.”