THAIS began the nail-biting wait late on Sunday to see whether the ruling junta will return to power as a civilian government, or if pro-democracy parties can triumph against the odds, as polls closed in the country’s first general election since a 2014 coup.

The Election Commission estimated 80 per cent of voters had turned out at schoolyards, temples and government offices across the nation, their enthusiasm fired by years of denied democracy.

Sunday’s crunch vote was foreshadowed by a cryptic last-minute warning from King Maha Vajiralongkorn to support “good” leaders to prevent “chaos”.

Thailand is a constitutional monarchy and the palace is nominally above politics. But the institution retains unassailable powers and is insulated from criticism by a harsh royal defamation law.

The election pits a royalist junta and allies against the election-winning machine of billionaire ex-premier Thaksin Shinawatra and an unpredictable wave of millions of first-time voters.

The kingdom remains bitterly divided despite the junta’s pledge to rescue it from a decade-long treadmill of protests and coups.

Politicians across the spectrum fear a stalemate under election rules, written by the junta, which limit the chances of any single party emerging with a comfortable parliamentary majority.

There are 51 million eligible voters and more than seven million first-timers aged 18-25.

Preliminary results were expected hours after the polls closed at 5pm local time (5pm Cambodian time).

“I want to see Thailand become more democratic and inequality eased from society,” said insurance company employee Pattrapong Waschiyapong at a Bangkok polling station.

Fears of the potential for foul play ricocheted across social media in a reflection of the lingering mistrust between rival political camps, in a country which last held a general election in 2011.

“Thai people come to vote because they want change,” said Somkid, 64, giving only one name, as she waited outside the headquarters of the Pheu Thai party.

“If there is any vote rigging there will be protests.”

The day was framed by the palace statement, which added further intrigue to an election that has repeatedly threatened to tip into chaos before a single ballot was cast.

It reiterated comments by late king Bhumibol Adulyadej from 1969 calling for people to “support good people to govern the society and control the bad people” to prevent them “creating chaos”.

King Maha Vajiralongkorn urged the public to “remember and be aware” of the remarks of his father, who died in 2016.

While there were no further clues as to who those “good people” might be, the phrase – “khon dee” in Thai – is habitually attached to royalist, establishment politicians.

Another royal command in February torpedoed the candidacy of the king’s elder sister Princess Ubolratana for prime minister of a party linked to Thaksin, a divisive ex-premier toppled by a 2006 coup.

Thaksin looms large

Thaksin has lived in self-exile since 2008, but he looms large over Sunday’s election.

His affiliated parties have won every Thai election since 2001, drawing on loyalty from rural and urban poor.

On Friday Ubolratana was guest of honour at the glitzy Hong Kong wedding of Thaksin’s daughter – with photos of the tycoon and the princess hugging and smiling going viral.

In Bangkok Sudarat Keyuraphan, the prime ministerial candidate for the largest Thaksin-linked party Pheu Thai, said she had witnessed “euphoria” at the ballot box.

The junta party, which is proposing army-chief-turned premier Prayut Chan-O-Cha for civilian prime minister after the polls, is under intense pressure to avoid humiliation in what is effectively a referendum on its popularity.

Prayut toppled the civilian government of Thaksin’s younger sister Yingluck in 2014.

The army and its allies in the Bangkok elite loathe the Shinawatras, accusing the clan of toxifying Thai politics and society with money, nepotism and graft.

The Shinawatras say they have simply recognised the economic and democratic aspirations of Thailand’s majority.

This time the junta has written new election rules aimed at curbing the number of seats big parties – specifically Pheu Thai – can win.

Phalang Pracharat in pole position

Pheu Thai is expected to again sweep the north and northeastern heartlands as it seeks to head an anti-junta coalition.

But a 250-member junta-appointed senate and a new proportional system were meant to have manoeuvered the junta party – Phalang Pracharat – into pole position.

With senate votes in hand, it needs just 126 lower house seats to secure a parliamentary majority.

It can cross that line comfortably in alliance with smaller parties.

Pheu Thai however needs 376 lower house seats to command an overall majority – near impossible without complex tie-ups across pro-democracy factions.

“A deadlock is very likely,” political scientist Napisa Waitoolkiat of Naresuan University said.

Many younger voters tired of the old political lines have pledged to support telegenic 40-year-old billionaire Thanathorn Juangroongruangkit.

The political newcomer’s Future Forward party has won fans with strong social media messaging and its strident anti-junta stance.

Others including Thailand’s oldest party the Democrats could play a key role.