Thai voters have rejected the military-backed government as two opposition parties appear to be set for coalition talks.
Initial results show the Move Forward and Pheu Thai parties surging ahead of Prime Minister Prayuth Chan-ocha.
The election has been described as a turning point for Thailand which has experienced military coups in its recent years.
Mr Prayuth led the last coup in 2014 and sought another term in office.
But he has faced strong election challenges from Move Forward and Pheu Thai which are two anti-military parties.
Move Forward is led by former tech executive Pita Limjaroenrat, while Paetongtarn Shinawatra – the daughter of former PM Thaksin Shinawatra – is the Pheu Thai candidate.
With 97% of the vote counted, a calculation by Reuters news agency based on data from the Election Commission suggested Move Forward would win the most seats followed by Pheu Thai in second place.
But despite their success, Move Forward and Pheu Thai may still face a battle to take power.
Under the country’s 2017 constitution, they need the support of senators hand-picked by the military – who get a say on who becomes the next prime minister and can form a government.
As the senators were all appointed by the coup leaders they have always voted in favour of the current, military-aligned government, and never in favour of the opposition.
Mr Pita described the result as “sensational” and promised his party would remain opposed to military-backed parties when forming a government.
The party would seek talks with Pheu Thai and a coalition deal was “definitely on the cards”, Mr Pita told reporters.
Pheu Thai leader Paetongtarn Shinawatra congratulated Move Forward on their success and said “we can work together”.
“We are ready to talk to Move Forward, but we are waiting for the official result,” she added.
Vote counting got underway after polls closed at 17:00 (10:00 GMT) on Sunday – nine hours after voting began at 95,000 polling stations across Thailand.
About 50 million people were expected to cast their ballots to elect 500 members of the lower house of parliament – and some two million people had voted early.
The Election Commission is not expected to officially confirm the final number of seats won by each party for several weeks.
But it marks a significant shift in public opinion in Thailand as voters of all ages appear to have been willing to take a chance on relatively untested and idealistic young politicians.
Back in 2014, Mr Prayuth, 69, seized power from the government of Mr Thaksin’s sister, Yingluck Shinawatra following months of turmoil.
Thailand held an election in 2019, but the results showed no clear party had won a majority.
Weeks later, a pro-military party formed the government and named Mr Prayuth as its PM candidate in a process that the opposition said was unfair.
The following year a controversial court ruling dissolved Future Forward, the previous iteration of Move Forward, which had performed strongly in the election thanks to the passionate support of younger voters.
That sparked off mass protests lasting six months which called for reform of the military and the monarchy.