Long-delayed results of Thailand's first election since a 2014 military coup show the opposition "democratic front" alliance won the most seats — but rules written by the ruling military junta mean a pro-army party will likely choose the prime minister.

Key points: Under post-coup, a junta-selected committee will appoint the Senate

Under post-coup, a junta-selected committee will appoint the Senate The Senate votes with the elected House of Representatives to choose the prime minister

The Senate votes with the elected House of Representatives to choose the prime minister It means that coup leader Prayuth Chan-ocha is likely to remain Thailand's leader

The opposition threatened to take legal action over results released Wednesday — which come more than six weeks after the election — saying that a new seat allocation formula robbed the alliance of a majority in the 500-seat House of Representatives.

The "democratic front" of seven parties won a combined 245 seats in the House, falling just short of a majority in the 500-seat lower house.

A small group of activists protested in Bangkok in the days after the election. ( Reuters: Soe Zeya Tun )

The pro-army Palang Pracharat party won 115 seats in the House while its allies won a further seven, according to the results from the Election Commission.

The results are likely to set up a period of coalition building, since neither side has enough votes to elect a prime minister.

Under rules introduced after the 2014 military coup, a junta-selected committee will appoint the Senate, the 250-seat upper house of Parliament that will vote together with the elected House to choose the leader.

It is likely that the party of coup leader Prayuth Chan-ocha will stay in power because it needs fewer allies among small and medium-sized parties to get to the 376 votes needed to elect the prime minister in the combined House and Senate vote.

Pro-military prime ministerial candidate Prayuth Chan-ocha hopes to maintain power after Thailand's election results were delayed. ( Reuters: Damir Sagolj )

General Prayuth's Palang Pracharat party said it was confident it would lead to the formation of the next government, but didn't name allies.

"We will coordinate with other parties who share our ideology and are interested in forming a government together," said its leader, Uttama Savanayana, a former minister under General Prayuth's previous cabinets.

The Pheu Thai party, allied to ousted Prime Minister Thaksin Shinawatra, vowed to "pursue every legal means" to reverse an Election Commission formula it says favoured tiny parties at the expense of its own larger vote-winners.

"The Pheu Thai Party sees the Election Commission's proceedings as deliberate actions and use of power in violations of the constitution and the [electoral] law," it said in a statement.

The party topped the field with 136 seats, while fellow anti-military party Future Forward won 80, lower than the 87 initially projected by the Election Commission.

Future Forward party secretary-general Piyabutr Saengkanokkul called the commission's calculations "absurd".

The Election Commission and the junta deny any bias in the electoral law.

Palang Pracharat needs control over only about 126 seats in the House to vote in Prayuth as prime minister, under the assumption it will get most or all of the junta-appointed Senate's 250 votes.

The results mean the party only needs to gain four or more votes from the 16 unaligned parties that won 131 seats combined.

Two seats remain in contention after the Election Commission ordered re-votes.

The electoral rules make it practically impossible for the opposition to overcome the Senate's vote to form a government.

But it had hoped gaining a majority in the lower house would allow it to block the junta from retaining nearly unrestrained power it has wielded since the military takeover five years ago.

Any government that emerges is likely to be weak, because even if the junta leader's party forms the government, it will still have to contend with the possibility of defections with allies in the lower house to pass legislation.

Space to play or pause, M to mute, left and right arrows to seek, up and down arrows for volume. Watch Duration: 33 seconds 33 s Thai officer checks soldiers' votes during news broadcast

Reuters