Thailand's 2014 coup leader and junta chief Prayut Chan-O-Cha is one step closer to power after a shock election Sunday that lifted his party ahead in the popular vote.
Army-aligned Phalang Pracharat won more than 7.6 million votes, about 400,000 votes ahead of Pheu Thai, the party linked to exiled former premier Thaksin Shinawatra.
But preliminary figures show Pheu Thai has won in 137 constituency seats nationwide, compared to Phalang Pracharat's 97.
So who is actually leading, and what happens next?
- Who won the election? -
Both parties have claimed the right to lead Thailand's next government, leaving voters confused.
Phalang Pracharat believes winning the popular vote gives them the mandate.
But Pheu Thai disputes this, saying they now hold more of the 350 available constituency seats in the 500-seat lower house.
This is where it gets tricky.
Both are now in negotiations with other smaller parties to cobble together a majority in the lower house.
But results for an additional 150 "party list" seats, which will take more of the popular vote into account, have yet to be released.
Loyalties up for grabs include Bhumjaithai, which won 39 constituency seats, and political newcomer Future Forward, led by telegenic frontman and fierce junta critic Thanathorn Juangroongruangkit.
All told, the victorious party need 376 seats of the 750-member combined upper and lower houses to pick a prime minister.
But the upper house or senate is a 250-member body appointed by the junta, virtually guaranteeing Phalang Pracharat success.
- Was it 'free and fair'? -
Billionaire Thaksin Shinawatra, who has been in self-exile since 2008, told AFP in an interview that the election was "definitely" rigged.
Pressure is mounting on the Election Commission to explain several allegations of irregularities, and the hashtag #RiggedElection has trended on Thai Twitter.
Poll monitor ANFREL says there were nearly 1.9 million invalidated ballots, or around 5.6 percent of the total, and the tabulation of votes was "deeply flawed".
But it also said that shortcomings may not significantly have impacted the result.
"I have brought up many, many aspects of this election and repeatedly said it did not meet with certain standards," said ANFREL secretary general Rohana Hettiarachchie, who pointed to the legal framework underpinning the poll such as the appointed senate.
But "I think it is unfair if we conclude whether it is free and fair or not."
A candidate from the Democrat Party -- which dropped to fifth in the popular vote -- filed a complaint Monday about vote-buying in a southern province the night before the poll.
According to the commission's own figures, the number of ballots cast in some provinces far exceeded the voter turnout -- but was dismissed as "human error" when questioned by reporters.
By Tuesday more than 700,000 people had signed a petition to dissolve the Election Commission.
Pheu Thai's prime minister candidate Sudarat Keyuraphan said her party was probing several irregularities in the polls.
- How did Prayut's party perform so well? -
Pheu Thai and other pro-democracy parties hoped to leverage discontent with a junta that has ruled Thailand for nearly five years after ousting the administration of Thaksin's sister Yingluck in 2014.
But before the elections, junta-aligned Phalang Pracharat poached more than 40 MPs from the Pheu Thai party, many of them stalwarts in their constituencies.
These politicians are often seen as the solvers of local problems, and Thai voters -- especially in more rural areas -- are likely to remain loyal to their patron instead of any party ideology.
Under the wing of most politicians are also people known as "canvassers" working to persuade locals -- either in cash or in kind.
Analysts say the impact canvassers have in elections is pivotal.
Phalang Pracharat may have also benefited from an election eve message from Thailand's king, who urged voters to support "good people" and not those who create "chaos".
The junta has portrayed itself as the defender of the monarchy.