Thai voters went to the polls on Sunday in a long-delayed election following a 2014 coup, a race that pits a military junta chief seeking to retain power against a "democratic front" led by the populist party he ousted.

Turnout was expected to be high among the 51.4 million Thais eligible to vote for the 500-seat House of Representatives, which will choose the next government along with a Senate that is appointed entirely by the ruling junta.

Thailand has been under direct military rule since then-army chief Prayuth Chan-ocha overthrew an elected government linked to exiled former Prime Minister Thaksin Shinawatra, who himself was thrown out by the army in 2006.

Critics have said a new, junta-written electoral system gives a built-in advantage to pro-military parties and appears designed to prevent the Thaksin-linked Pheu Thai Party from returning to power.

Pro-Thaksin parties have won every election since 2001, but the past 15 years have seen crippling street protests that destabilised the government and hamstrung business.

Thailand's transgender candidate Show all 6 1 /6 Thailand's transgender candidate Thailand's transgender candidate transgender2.jpg In this Thursday, Feb. 14, 2019, photo, Pauline Ngarmpring poses for a photograph at the Mahachon party head office in Bangkok, Thailand. As Pinit Ngarmpring, he was a CEO and sports promoter, well known in the world of Thai soccer. Now, under her preferred new name of Pauline Ngarmpring, she's pursuing a bid to become the country's first transgender prime minister. (AP Photo/Gemunu Amarasinghe) (AP Photo/Gemunu Amarasinghe) Thailand's transgender candidate transgender3.jpg In this Wednesday, Feb. 13, 2019, photo, Pauline Ngarmpring, a transgender person and a prime minister candidate in the upcoming Thai general election, speaks during an interview with The Associated Press in Bangkok, Thailand. As Pinit Ngarmpring, he was a CEO and sports promoter, well known in the world of Thai soccer. Now, under her preferred new name of Pauline Ngarmpring, she's pursuing a bid to become the country's first transgender prime minister. (AP Photo/Gemunu Amarasinghe) (AP Photo/Gemunu Amarasinghe) Thailand's transgender candidate transgender4.jpg In this Wednesday, Feb. 13, 2019, photo, Pauline Ngarmpring, right, a transgender person and a prime minister candidate, and Namklenginarin, center, a candidate for the parliament, both representing the Mahachon party for the upcoming Thai general election, greet people during an election campaign in Bangkok, Thailand. As Pinit Ngarmpring, he was a CEO and sports promoter, well known in the world of Thai soccer. Now, under her preferred new name of Pauline Ngarmpring, she's pursuing a bid to become the country's first transgender prime minister. (AP Photo/Gemunu Amarasinghe) (AP Photo/Gemunu Amarasinghe) Thailand's transgender candidate transgender5.jpg In this Wednesday, Feb. 13, 2019, photo, A transgender person and a prime minister candidate Pauline Ngarmpring, center, and house candidate Namklenginarin, right, both representing the Mahachon party for the upcoming general election, greet people during an election campaign in Bangkok, Thailand. As Pinit Ngarmpring, he was a CEO and sports promoter, well known in the world of Thai soccer. Now, under her preferred new name of Pauline Ngarmpring, she's pursuing a bid to become the country's first transgender prime minister. (AP Photo/Gemunu Amarasinghe) (AP Photo/Gemunu Amarasinghe) Thailand's transgender candidate transgender6.jpg In this Wednesday, Feb. 13, 2019, photo, Pauline Ngarmpring center, a transgender person and a prime minister candidate of the Mahachon party for the upcoming general election, greets people during an election campaign in Bangkok, Thailand. As Pinit Ngarmpring, he was a CEO and sports promoter, well known in the world of Thai soccer. Now, under her preferred new name of Pauline Ngarmpring, she's pursuing a bid to become the country's first transgender prime minister. (AP Photo/Gemunu Amarasinghe) (AP Photo/Gemunu Amarasinghe) Thailand's transgender candidate transgender1.jpg In this Wednesday, Feb. 13, 2019 photo, Pauline Ngarmpring, left, speaks with workers of a roadside massage parlor during an election campaign in Bangkok, Thailand. As Pinit Ngarmpring, he was a CEO and sports promoter, well known in the world of Thai soccer. Now, under her preferred new name of Pauline Ngarmpring, she's pursuing a bid to become the country's first transgender prime minister. (AP Photo/Gemunu Amarasinghe) (AP Photo/Gemunu Amarasinghe)

Mr Chan-ocha's party campaigned on maintaining order and upholding traditional values of loyalty and devotion to the monarch.

"I am happy to see citizens come out and exercise their voting rights," Mr Chan-ocha told reporters on Sunday after casting his vote. "I want to see love and unity. Everybody has one vote, one voice. Everybody wants democracy."

The anti-Thaksin Yellow Shirts, mostly middle class and urban royalists who accuse his parties of corruption, have repeatedly taken to the streets, prompting the military to launch two coups in a decade.

Thaksin's supporters, known as the Red Shirts, also occupied much of Bangkok's main business and shopping districts for months in 2010 after a court dissolved a pro-Thaksin government, again paralysing commerce until a crackdown that left at least 90 people dead and saw landmark buildings burned.

Thailand debuts elephant-friendly tourism

While the election results are due to be announced within a few hours of polls closing at 5pm (10am GMT), the make-up of the next government may not be clear for weeks, since no one party is likely to have enough seats for an outright win.

The country's king made an unexpected and cryptic statement hours before the vote, recalling a comment made by his late father in 1969 on the need to put "good people" in power and to prevent "bad people from ... creating chaos".

Although he did not refer to any of the sides in the race, there was speculation on social media that it was a coded reference to the country's political factions - broadly the middle class and urban establishment, who identify with the monarchy and the military, and their pro-Thaksin opponents.

The king's intervention was a departure from the approach of his father, who in his latter years usually kept a distance between the monarchy and politics.

It followed a startling turn of events last month when a party allied to Pheu Thai nominated Princess Ubolratana, the king's sister, as its prime ministerial candidate. It was then disqualified by a court after the king said it was "inappropriate" for members of the royal family to enter politics.

"What happened last month ... and then the announcement last night shows that, in contrast to the former reign, that the monarchy is actively interested in monitoring what's going on and it feels that it has some stake in the future direction of the country," said David Streckfuss, a Thailand-based independent scholar.

The junta-written electoral rules ensure the military will continue to have a say in the next government, even if Mr Chan-ocha does not stay on as prime minister.

Pro-Thaksin parties are expected to win the largest number of seats in the House of Representatives. However, the new system appears designed to prevent it from forming a government because it includes the junta-appointed 250-seat Senate in the vote for prime minister.

The provision means Mr Chan-ocha's Palang Pracharat Party and allies have to win only 126 seats in the House, while Pheu Thai and its potential "democratic front" partners would need 376.

Among the potential Pheu Thai allies is the new Future Forward Party, led by 40-year-old billionaire Thanathorn Juangroongruangkit, whose criticism of the junta has been scathing and faces charges under the Computer Crimes Act for a critical Facebook speech. Prosecutors have said they will decide whether to put him on trial days after the election.

Thailand's rebel female Buddhist monks defy tradition Show all 20 1 /20 Thailand's rebel female Buddhist monks defy tradition Thailand's rebel female Buddhist monks defy tradition Thai women devotees attend an icebreaking session ahead of their ordination to be novice monks at the Songdhammakalyani monastery, Nakhon Pathom province, Thailand. Officially, only men can become monks and novices in Thailand under a Buddhist order that, since 1928, has forbidden the ordination of women. A growing number of women defy generations of Thai Buddhist tradition by becoming ordained as novice monks at the unrecognised all-female monastery Reuters Thailand's rebel female Buddhist monks defy tradition Thai women devotees practice during a first orientation to become Buddhist novice monks Reuters Thailand's rebel female Buddhist monks defy tradition Dhammananda Bhikkhuni, 74, abbess of the monastery, plays with her dog Reuters Thailand's rebel female Buddhist monks defy tradition Thai women devotees have their hair cut during a mass female Buddhist novice monk ordination ceremony Reuters Thailand's rebel female Buddhist monks defy tradition Novice monks walk in line to receive food offerings Reuters Thailand's rebel female Buddhist monks defy tradition Novice monks walk in line during their ordination ceremony Reuters Thailand's rebel female Buddhist monks defy tradition Thai women devotees Reuters Thailand's rebel female Buddhist monks defy tradition Saffron robes before before ordination ceremony Reuters Thailand's rebel female Buddhist monks defy tradition Boodsabann Chanthawong, 49, a businesswoman, works on her mobile phone as she rides on a train, weeks ahead of her ordination Reuters Thailand's rebel female Buddhist monks defy tradition A painting of a female Buddhist monk Reuters Thailand's rebel female Buddhist monks defy tradition A devotee has her hair cut Reuters Thailand's rebel female Buddhist monks defy tradition Novice monks gather for a group photo Reuters Thailand's rebel female Buddhist monks defy tradition Novice monks pray during a morning routine Reuters Thailand's rebel female Buddhist monks defy tradition A Thai woman devotee who ended her novice monkhood has her head cleaned by Dhammananda Bhikkhuni Reuters Thailand's rebel female Buddhist monks defy tradition Thai women devotees carry their saffron robes Reuters Thailand's rebel female Buddhist monks defy tradition Female Buddha statues on display at the Songdhammakalyani monastery Reuters Thailand's rebel female Buddhist monks defy tradition Devotees in white robes pray Reuters Thailand's rebel female Buddhist monks defy tradition Devotees walk in line during their Buddhist novice monk ordination ceremony Reuters Thailand's rebel female Buddhist monks defy tradition Thai women return their saffron robes after ending their novice monkhood Reuters Thailand's rebel female Buddhist monks defy tradition Boodsabann Chanthawong works with her husband at her stall near her house, days after she ended her novice monkhood Reuters

"The current government has not done much for the economy. Old parties may end up fighting again, so I think the new party is better," said Somkiat Rattanawibun, a 42-year-old business owner told Reuters after casting his vote in Bangkok.

Two officially non-aligned parties could be decisive in whether pro-military or "democratic front" factions make up the next government.

Former Prime Minister Abhisit Vejjajiva, leader of the anti-Thaksin Democrats, has portrayed himself as a third way between the "dictatorship" of keeping Mr Chan-ocha and a return to the "corruption" on Thaksinism, but he would likely have to side with one or the other to form a government.

The Bhumjaithai Party of Anutin Charnvirakul placed third in the last election of 2011 and has grabbed attention for populist campaign promises such as legalisation of recreational marijuana and a four-day work week. It's unclear which side he would choose.

Regardless of the make-up of the government, the election result is likely to yield a shaky coalition that will do little to soothe Thailand's deep political divides and may not be able to accomplish much, said Paul Chambers, lecturer in political science at Naresuan University in northern Thailand.

"There could be a stable government coming out of it in the short term," he said. "But that kind of coalition is not going to last that long."