Vote counting got under way in Thailand's general election Sunday with pro-democracy opposition parties tipped to defeat the conservative military-backed government of prime minister Prayut Chan-O-Cha after almost a decade in power.

Opinion surveys pointed to a resounding defeat for ex-army chief and coup leader Prayut after a campaign that played out as a clash between a young generation yearning for change and the traditionalist, royalist establishment.

The main opposition Pheu Thai party, fronted by the daughter of billionaire former premier Thaksin Shinawatra, was ahead in final opinion polls.

But in a kingdom where victory at the ballot box has often been trumped by coups and court orders, there are fears the military could seek to cling on, raising the prospect of fresh instability.

Polling stations closed at 5:00 pm (1000 GMT) after a smooth day of voting, with no major problems reported by Thai media.

Preliminary results are expected later in the evening, though the final number of seats won by each party will not be officially confirmed for several weeks.

After casting her ballot in Bangkok, Pheu Thai's main candidate Paetongtarn Shinawatra showed no signs of nerves.

"Today is going to be a good day. I have very positive energy about it," the 36-year-old told reporters, smiling broadly.

Millions of Thais cast ballots at 95,000 polling stations scattered from the lush-forested mountains of the north to the idyllic sands of the southern beaches.

A turnout of 90 percent in last Sunday's early round of voting pointed to an electorate looking for change, but the opposition faces an uphill battle to secure power, thanks to the junta-scripted 2017 constitution.

The new premier will be chosen jointly by the 500 elected MPs and 250 senate members appointed by Prayut's junta -- stacking the deck in the army's favour.

In the controversial last election in 2019, Prayut rode senate support to become prime minister at the head of a complex multi-party coalition.

Protest legacy

The election is the first since major youth-led pro-democracy protests erupted across Bangkok in 2020 with demands to curb the power and spending of Thailand's king -- breaching a long-held taboo on questioning the monarchy.

The demonstrations petered out as Covid-19 curbs were imposed and dozens of leaders were arrested, but their energy has fuelled growing support for the more radical opposition Move Forward Party (MFP).

As he arrived to vote in Bangkok, MFP leader Pita Limjaroenrat, 42, said he expected a "historic turnout".

"Younger generations these days care about their rights and they will come out to vote," he told reporters.

While MFP is looking for support from millennial and Gen Z voters -- who make up nearly half the 52 million-strong electorate -- Pheu Thai's base is in the rural northeast where voters are still grateful for the welfare policies implemented by Thaksin in the early 2000s.

Prayut also urged voters to turn out in large numbers as he cast his ballot on Sunday.

The former general has made an unashamedly nationalist pitch to older voters, painting himself as the only candidate capable of saving Thailand from chaos and ruin.

But he has lagged badly in the polls, blamed for a sputtering economy and feeble recovery from the pandemic, which battered the kingdom's crucial tourism industry.

Voter Pakorn Adulpan, 85, said he was impressed by the quality of this year's contest.

"I am very hopeful because there is strong competition between many talented candidates, compared to the elections in the past," he told AFP.

Rights groups accuse Prayut of overseeing a major crackdown on basic freedoms, with a huge spike in prosecutions under Thailand's draconian royal defamation laws.

The country has seen a dozen coups in the last century and has been locked over the last two decades in a rolling cycle of street protests, coups and court orders dissolving political parties.

The Shinawatra family's bitter tussle with the royalist-military establishment has been at the heart of the drama, with Thaksin ousted in a 2006 coup and his sister Yingluck unseated by Prayut in 2014.

An unclear or disputed result this time could lead to a fresh round of demonstrations and instability.

Adding to the uncertainty, rumours are already swirling that MFP could be dissolved by court order -- the same fate that befell its predecessor Future Forward Party after it performed unexpectedly well at the 2019 poll.

Once results come in, attention will turn to the Electoral Commission, the judges and the generals to see what the next steps will be.