By Panu Wongcha-um and Panarat Thepgumpanat
BANGKOK (Reuters) -Thailand's opposition secured a stunning election win on Sunday after trouncing parties allied with the military, setting the stage for a flurry of deal-making over forming a government in a bid to end nearly a decade of conservative, army-backed rule.
The liberal Move Forward party and the populist Pheu Thai Party were far out in front with 99% of votes counted, but it was far from certain either will form the next government, with parliamentary rules written by the military after its 2014 coup skewed in its favour.
To rule, the opposition parties will need to strike deals and muster support from multiple camps, including members of a junta-appointed Senate that has sided with military parties and gets to vote on who becomes prime minister and form the next administration.
Sunday's election was the latest bout in a long-running battle for power between Pheu Thai, the populist juggernaut of the billionaire Shinawatra family, and a nexus of old money, conservatives and military with influence over key institutions at the heart of two decades of turmoil.
But the staggering performance by Move Forward, riding a wave of support from young voters, will test the resolve of Thailand's establishment and ruling parties after it came close to a clean sweep of the capital Bangkok on a platform of institutional reform and dismantling monopolies.
Move Forward came top, followed closely by Pheu Thai, the preliminary results showed. According to a Reuters calculation, both were set to win more than triple the number of seats of Palang Pracharat, the political vehicle of the junta, and the army-backed United Thai Nation party.
Move Forward leader Pita Limjaroenrat, a 42-year-old former executive of a ride-hailing app, described the outcome as "sensational" and vowed to stay true to his party's values when forming a government.
"It will be anti- dictator-backed, military-backed parties, for sure," he told reporters. "It's safe to assume that minority government is no longer possible here in Thailand."
He said he remained open to an alliance with Pheu Thai, but has set his sights set on being prime minister.
"It is now clear the Move Forward Party has received the overwhelming support from the people around the country," he said on Twitter.
The preliminary results will be a crushing blow for the military and its allies. But with parliamentary rules on their side and influential figures behind them and involved behind the scenes, they could still have a role in government.
Prime Minister Prayuth Chan-ocha, a retired general who led the last coup, had campaigned on continuity after nine years in charge, warning a change in government could lead to conflict.
On Sunday, he slipped away quietly from his United Thai Nation party headquarters, where there were few supporters to be seen.
A handful of staff sat beside plates of uneaten food as a giant television screen showed a live speech by Move Forward's leader.
"I hope the country will be peaceful and prosper," Prayuth told reporters. "I respect democracy and the election. Thank you."
Pheu Thai had been expected to win having won most votes in every ballot since 2001, including two landslide victories. Three of its four governments have been ousted from office.
Founded by the polarising self-exiled tycoon Thaksin Shinawatra, Pheu Thai remains hugely popular among the working classes and was banking on being swept back to power in a landslide on nostalgia for its populist policies like cheap healthcare, micro-loans and generous farming subsidies.
Thaksin's daughter Paetongtarn, 36, has been tipped to follow in the footsteps of her father and of her aunt, Yingluck Shinawatra, and become prime minister. Yingluck and Thaksin were both overthrown in coups.
Paetongtarn said she was happy for Move Forward, but it was too soon to discuss alliances.
"The voice of the people is most important," she said.
Move Forward saw a late-stage rally in opinion polls and was betting on 3.3 million first-time voters getting behind its liberal agenda, including plans to weaken the military's political role and amend a strict law on royal insults that critics say is used to stifle dissent.
Thitinan Pongsudhirak, a political scientist at Chulalongkorn University, said Move Forward's surge demonstrated a major shift in Thai politics.
"Pheu Thai fought the wrong war. Pheu Thai fought the populism war that it already won," he said.
"Move Forward takes the game to the next level with institutional reform. That's the new battleground in Thai politics."
(Reporting by Chayut Setboonsarng; Panarat Thepgumpanat, Poppy McPherson, Orathai Sriring, Kwang Jiraporn Kuhakan and Panu Wongcha-um; Writing by Martin Petty; Editing by Kanupriya Kapoor, Sharon Singleton, Ros Russell and Cynthia Osterman)