Nearly five years after a coup, Thailand has voted in a long-delayed election setting a military-backed party against the populist political force the generals overthrew.

Prime Minister Prayuth Chan-ocha, the blunt-speaking army chief who led the 2014 coup, is hoping to extend his hold on power after engineering a new political system that aims to stifle the influence of big political parties not aligned with the military.

Voting stations closed at 5pm and meaningful results were expected within several hours, but the formation of a new government could take weeks of haggling.

About 51 million Thais were eligible to vote. Leaders of political parties opposed to military rule urged a high turnout as the only way to derail Mr Prayuth’s plans.

Thailand Election
Thailand’s Prime Minister Prayuth Chan-ocha casts his vote (Gemunu Amarasinghe/AP)

Mr Prayuth was among the first to vote in Bangkok, the capital, arriving in a black Mercedes after polling booths opened at 8am.

“I hope everyone helps each other by going to vote today as it’s everyone’s right,” he told reporters after voting. He played golf later in the morning before heading to an army base to await results.

The election is the latest chapter in a nearly two-decade struggle between conservative forces including the military and the political machine of former prime minister Thaksin Shinawatra, a tycoon who upended tradition-bound Thailand’s politics with a populist political revolution.

Mr Thaksin was ousted in a 2006 military coup and now lives in exile abroad to avoid a prison term, but parties allied with him have won every election since 2001.

His sister, Yingluck Shinawatra, who led the government that was ousted in 2014, also fled the country after what supporters said was a politically motivated corruption prosecution.

After the coup, political party gatherings were banned and pro-democracy activists and other dissenters were regularly arrested, interrogated and imprisoned. Just days before Sunday’s election, the Thaksin-allied Pheu Thai party said the houses of party officials and its campaign canvassers in some provinces were searched by military personnel in an act of intimidation.

The party’s leader, Sudarat Keyuraphan, said after voting in Bangkok’s Ladprao district that she was confident of winning.

Thailand Election
Leader of Pheu Thai Party Sudarat Keyuraphan (Sakchai Lalit/AP)

“I don’t say it’ll be a landslide. I don’t know. Depends on the people. But I think we can win this election,” she said.

Thailand’s powerful King Maha Vajiralongkorn issued a statement on the eve of the election that said the role of leaders is to stop “bad people” from gaining power and causing chaos.

It was also broadcast on Thai television stations minutes before voting started.

Invoking a speech by his father, the previous Thai king who died in 2016 after reigning for seven decades, King Vajiralongkorn said not all citizens can be transformed into good people so leaders must be given support in ruling to create a peaceful nation.

He urged government officials, soldiers and civil servants to look after national security.

It was the monarch’s second notable intervention in politics recently. Last month, he demanded his sister Princess Ubolratana Mahidol withdraw as a prime ministerial candidate for a small Thaksin-allied party within 24 hours of her announcement.