Soldiers flock to polling precincts to cast their vote on March 24 in Bangkok.
Bangkok CNN  — 

Thailand’s main opposition party has won more seats than anyone else in the country’s parliament – in the first election since a military coup five years ago – but it won’t get to choose the country’s next leader.

Pheu Thai took 136 seats, according to official figures released Wednesday, while the pro-military Palang Pracharat party took 115. Pheu Thai is aligned with former Prime Minister Thaksin Shinawatra, whose allies were ousted in the 2014 coup.

Based on the official tally, Pheu Thai and its coalition partners appear to have taken a total of 245 of the 500 seats in the lower house, six short of a majority.

But that won’t be enough to form a government or choose the next prime minister. That decision is made by both houses of Parliament, and the country’s 250-seat Senate is chosen entirely by the military, which will almost certainty vote to keep junta leader Prayut Chan-o-cha in office.

Thai Prime Minister Prayut Chan-O-Cha speaks during a joint news conference with his Malaysian counterpart at the Government House in Bangkok on October 24, 2018.

Critics have complained that the odds were stacked against the opposition from the start in a vote seen as a contest between a pro-military bloc that wants to keep power and pro-democracy forces.

Leaders of the National Council for Peace and Order, the junta’s official name, have grown accustomed to office. A military-drafted 2017 constitution aims to prevent big parties such as Pheu Thai from returning to office – and to ensure the army still has a major say, regardless who wins the election.

The outcome of the March 24 vote was initially unclear. No party took a decisive lead and both Pheu Thai and Palang Pracharat claimed the right to form a coalition. Results were finally released Wednesday after weeks of delay.

The contest was also dogged by allegations of voting irregularities, leading one non-governmental watchdog to determine that the election was “not free and fair.”

CNN’s Helen Regan contributed reporting.