The party allied to Thailand's ousted PM Thaksin Shinawatra has won the general election, initial results from the Election Commission show.
Samak Sundaravej's People Power Party (PPP) won 228 seats in the 480-seat house, short of the 241 needed for an absolute majority.
The election is the first since the 2006 coup that overthrew Mr Thaksin.
Correspondents say the result is a big setback for the military, which has tried to curb Mr Thaksin's influence.
The Election Commission said about 93% of votes had been counted and the situation would now not change greatly.
The PPP's main rival, the Democrat Party, is set to win 166 seats and Chart Thai 39.
Mr Samak, 72, claimed victory, saying: "I will be the next prime minister for sure."
He added: "I invite all the parties to join our government."
The leader of the PPP's main rival, the Democrats, Abhisit Vejjajiva, said the election had been a "close race".
"If the PPP succeeds in forming a coalition, the Democrat Party is ready to become the opposition. If the PPP fails, then the Democrat Party is ready to form its own coalition," he said.
Mr Samak said he had spoken to Mr Thaksin, who is in Hong Kong, by telephone.
"Thaksin said 'congratulations'," Mr Samak said.
The PPP leader added: "This is a victory for all Thai people who unreasonably lost their freedom on 19 September."
That was the date in 2006 when the military removed Mr Thaksin and his Thai Rak Thai party from power.
Mr Thaksin, who is now banned from Thai politics, has since lived in self-imposed exile abroad, mainly in Britain.
However his allies have promised he would return and that the five-year political ban on him would be overturned.
Mr Samak said on Sunday: "Thaksin said he will come back after the government is formed."
If he does return to Thailand, Mr Thaksin will have to answer a number of corruption charges levelled against him in the courts.
Election monitors said that voting had mostly proceeded smoothly and been well-organised, despite complaints of vote-buying and other irregularities.
The PPP has concentrated mainly on the poor, rural vote that buoyed Mr Thaksin, while the Democrats have relied on the middle-class urban vote.
The BBC's Jonathan Head says the vote is a dramatic repudiation of the coup, but that it is hard to predict how the military will react to the result.
He says Mr Thaksin still has many enemies in the business and bureaucratic elite and in Bangkok's middle class.
And if there is a coalition, our correspondent says, the resulting multi-party government could well prove weak and short-lived.