BANGKOK (Reuters) - Thailand’s first general election since a military coup five years ago was thrown into disarray on Monday as two opposition parties alleged cheating and the election commission said it could be weeks until the make-up of parliament becomes clear.

Confusion over the outcome of Sunday’s election raised the specter of a protracted struggle to form a government, spoiling hopes of a clear cut result that could have ended 15 years of political turmoil in Southeast Asia’s second largest economy.

Both the pro-army party seeking to keep coup leader Prayuth Chan-ocha on as prime minister and the opposition party linked to self-exiled former premier Thaksin Shinawatra, claimed they would command enough parliamentary seats to form a coalition government.

The pro-Thaksin Pheu Thai party said it was considering a legal challenge over what it said were poll irregularities after partial results showed Prayuth’s Palang Pracharat party with an unexpected lead in the popular vote.

The strong early showing for Palang Pracharat increased the likelihood that Prayuth, who was army chief when he overthrew a Pheu Thai government in 2014, would stay in power, although that outcome was not certain.

“There are irregularities in this election that we’re not comfortable with. These affect the nation’s credibility and people’s trust,” said Sudarat Keyuraphan, candidate for prime minister of the Pheu Thai Party.

“We’ve voiced our concerns before for vote-buying, abuse of power, and cheating. All three have manifested. We will fight back through legal means,” she told a news conference.

Thailand has been racked since 2004 by street protests of both opponents and supporters of Thaksin. Parties linked to Thaksin have won every previous election since 2001, but the populist telecoms billionaire was thrown out by the army in 2006 and a government led by his sister was ousted in 2014.

Thaksin wrote an opinion piece headlined “The Election in Thailand Was Rigged” in The New York Times on Monday.

“I knew that the junta running Thailand wanted to stay in power, but I cannot believe how far it has gone to manipulate the general election on Sunday,” he wrote.

Earlier on Monday, election commission official Nat Laosisawakul blamed delays and irregularities in results on “human error” and said a full count of the vote would be released on Friday.

“We have nothing to hide,” he said.

Election in Thailand interactive graphic: tmsnrt.rs/2CrED4M

Slideshow ( 16 images )

DECK STACKED FOR MILITARY

The lower house and the upper house Senate, whose 250 members are appointed by the junta, will together select the next prime minister based on the support of a simple majority of 376 lawmakers.

That means Prayuth’s party and allies have to win only 126 seats in the lower house to vote him in as prime minister, while Pheu Thai and its potential “democratic front” partners would need 376 all from the lower house to choose the next premier.

Slideshow ( 16 images )

The House of Representatives, the lower house, has a total 500 seats, and on Monday the Election Commission posted the winners of the 350 seats that were contested on a first-past-the post basis.

The, as yet, unofficial results showed Pheu Thai leading with 137 seats to 96 seats for junta leader Prayuth’s party.

However, official results for the lower house’s remaining 150 “party seats”, which will be allocated by a complex formula involving voter turnout, will not be announced until May 9.

It might, however, be possible to roughly calculate the shares of the 150 “party seats” on Friday, when the Election Commission is due to give a breakdown of votes cast.

“CHEATING” TRENDS ON TWITTER

The strong popular vote showing by the pro-junta Palang Pracharat Party stunned voters who had hoped the poll would loosen the grip that traditional elites and the military hold on power in a country that has one of the highest measures of inequality in the world.

Many Thais took to social media to voice their suspicions about the results of an election that critics had said was systematically skewed in favor of the military from the outset because of the junta-appointed Senate’s role in selecting the prime minister.

Thai-language hashtags that translated as “Election Commission screw-up” and “cheating the election” were trending on Twitter in Thailand.

Many tweets referred to inconsistencies between the numbers for voter turnout and ballots cast in some parliamentary constituencies. Some questioned the overall turnout of less than 70 percent, which was much lower than expected.

Future Forward, a new party that appears to have made a spectacular election debut, winning 30 of the 350 constituency seats thanks to its appeal to young voters, also questioned the poll numbers.

“There are obviously some irregularities with the numbers because they don’t add up. This is making people skeptical of the election results,” said Future Forward spokeswoman Pannika Wanich.

A change.org petition launched a week ago to impeach the Election Commission had garnered almost 600,000 signatures by Monday evening, up from around 200,000 at the start of the day.