Image copyright Reuters

Thailand has held its first general election since a military coup in 2014.

The country has long been politically split between populists largely tapping into the rural and poorer sections of the population, and their opponents who tend to support the military and win votes from the urban middle class and elites.

A new constitution, introduced under the military leadership, changed the electoral process in a way that makes it likely it will retain control.

This means the country looks set to remain deeply divided between pro-military forces and their populist opponents.

A political rollercoaster ride

The election is seen as a culmination of a decade-long struggle by the military and political establishment to curb the influence of former prime minister Thaksin Shinawatra.

Media playback is unsupported on your device Media caption Why young voters could be key in Thailand's election

The billionaire businessman rose to power in the 2001 by mobilising poorer, rural areas that felt increasingly left behind by the country's economic progress.

He was ousted in 2006 by a military coup and his sister Yingluck Shinawatra, who followed him into politics suffered the same fate eight years later.

While there's hope this election will help usher Thailand towards democracy, there's also ample reason to be cautious.

Thailand is no stranger to political disruption and instability. The 2014 coup was the 12th time the military has toppled the government since the end of absolute monarchy in the 1930s.

So who's expected to win?

If all goes well for the military, the coup leader and current Prime Minister Prayuth Chan-ocha will stay in power, backed by a political majority.

If things don't go well for them, he is likely to remain in power - but with a minority government facing political gridlock.

Image copyright Reuters Image caption Prayuth Chan-ocha, Thailand's current and likely future PM

The military in 2017 introduced a new constitution which critics say is primarily designed to keep pro-military forces in power.

How? Thailand's electorate only votes for the 500-seat lower house of parliament. The members of the 250-seat upper house are appointed by the military.

But it's the combined votes from both houses that will select the future prime minister.

Intricate arithmetic

Let's do the maths: Opposition groups would need 376 of those votes to get their candidate elected. And all those 376 must come from the lower house. The senators, appointed by the military, are likely to back the military's candidate.

Hence, Gen Prayuth is highly likely to remain in power, even if parties backing him don't do so well at the ballot box.

Clearly, this would be the least desirable outcome for the military. Gen Prayuth would have a hard time governing with only minority backing in the lower house.

Yet a prime minister from the Thaksin camp is extremely unlikely - they'd need a landslide win of some 75% to get those 376 seats.

Who's running?

Pheu Thai, the party founded by Mr Thaksin, is expected to once again be the strongest party. It's still seen as a vehicle for its founder's populist policies although Mr Thaksin himself can't run or return should they win.

Image copyright Reuters Image caption Ousted leader Thaksin Shinawatra remains a powerful force in Thai politics

Both he and his sister Yingluck are currently in self-imposed exile and wanted in Thailand on charges of abuse of power and negligence, so the party has picked close Thaksin-ally Sudarat Keyuraphan as candidate.

As the new constitution introduced a ceiling on how many seats each party can win, Pheu Thai has created smaller splinter parties to get around that.

One such party was Thai Raksa Chart, seen largely as a proxy for Pheu Thai.

A royal candidate - nearly

Thai Raksa Chart was at the heart of a major political drama when in February a sister of the king was listed as the party's candidate for prime minister.

Traditionally, the royals are not involved in politics and her announcement sent shockwaves through the political establishment.

Soon after though, the king criticised her political bid and so she withdrew. Thai Raksa Chart was subsequently dissolved by the constitutional court.

Image copyright Reuters Image caption Princess Ubolratana had a short-lived political career

Pro-Thaksin parties now have very little chance of winning an outright majority in the lower house, although Pheu Thai is still expected to be by some margin the largest party.

Who will side with the military?

On the other side of the political spectrum are the main backers of the military junta: Palang Pracha Rath (PPRP) - Power of the People's State - which was formed last year. Gen Prayuth is its sole candidate for prime minister.

An ex-general, he was one of the leaders of the 2014 coup but has since retired from the military and became civilian prime minister.

Image copyright Getty Images Image caption Future Forward leader Thanathorn Juangroongruangkit has pledged to bring in sweeping reforms

The oldest establishment party is called the Democrats. While clearly in the anti-Thaksin camp, they have also explicitly ruled out backing pro-military forces.

A new party in the race is Future Forward which is also opposed to the military and is thought to possibly back Pheu Thai.

The military's struggle to win parties to support its side means the post-election outcome remains uncertain.

If pro-military forces do very poorly, Mr Prayuth may still be elected as prime minister but would have a very hard time governing and could lose credibility among voters.

Will there be unrest?

The two sides of Thailand's political divide have a history of taking their cause to the streets.

Over the past decade, protests by the pro-Thaksin Red Shirts versus the pro-establishment Yellow Shirts have several times paralysed Bangkok, raising the spectre of a possible escalation into violence.

Image copyright Getty Images Image caption Thailand has seen intense political protests over the past decades

The recent constitutional changes are clearly geared to keeping the military in power. While they are likely to do exactly that, this will also make it a lot easier for the losing side to discredit the vote.

This in turn could lead to political gridlock, tensions and even fresh unrest.