The court judges ruled in six to three votes that the February 2 election was unconstitutional because voting failed to take place on the same day around the country. (Agencies)
Anti-government protesters had stopped voting in about a fifth of constituencies and in 28 of them, voting was not possible at all because candidates were unable to register.
The protests are the latest chapter in an eight-year crisis that pits Bangkok's middle class and royalist establishment against supporters of Prime Minister Yingluck Shinawatra and her brother, ex-premier Thaksin Shinawatra, who was toppled by the army in 2006 and lives in exile to avoid a jail term for graft.
Over the past five months, the protesters have shut government offices and at times blocked major thoroughfares in Bangkok to try to force Yingluck out. Twenty-three people have died and hundreds have been injured in the violence.
The number of protesters has dwindled in recent weeks and the streets have been relatively calm since several big protest camps were shut at the start of March, allowing the government to lift a state of emergency on Wednesday. But the focus has shifted to the courts, in particular to the prospect of Yingluck being impeached over a rice scheme that has gone disastrously wrong, with hundreds of thousands of farmers not getting paid for grain sold to the state since October.
"Independent agencies are being quite obvious that they want to remove her and her entire cabinet to create a power vacuum, claim that elections can't be held and then nominate a prime minister of their choice," said Kan Yuenyong, a political analyst at the Siam Intelligence Unit, referring to the courts and the anti-corruption commission.
"If they run with this plan, then the government's supporters will fight back and the next half of the year will be much worse than what we saw in the first half," he said.
Thaksin's "red shirt" supporters, who are strong in the north and northeast, are beginning to sound more militant, raising the prospect of more violence if Yingluck is forced out by the courts, the anti-corruption commission or by other means.
The National Anti-Corruption Commission could recommend impeachment in coming days, probably by March 31.
She could then be removed from office by the upper house Senate, which is likely to have an anti-Thaksin majority after an election for half its members on March 30.
Some analysts say it will fall to the Senate to then appoint a "neutral" prime minister, probably the type of establishment figure the protesters have been demanding all along. It is unclear when a new election will take place.
Somchai Srisutthiyakorn, an Election Commission member, offered two options: "The commission could discuss with the government about issuing a new royal decree for a new date or we could ask the heads of all political parties to decide together when best to set the new election date," he told reporters.
A spokesman for the opposition Democrat Party has been quoted as saying it would boycott any vote, as it did in February, but after Friday's decision he said it might be prepared to take part.
"We're ready to join a new election but it depends on the government and whether the political situation is stable enough to hold a new vote," Chavanond Intarakomalyasut said.
Protest leader Suthep Thaugsuban, who was a deputy prime minister under the previous Democrat-led government, has shown no willingness to compromise.
"If the court rules the election void, don't even dream that there will be another election. If a new election date is declared, then we'll take care of every province and the election won't be successful again," he told supporters late on Thursday.
There was no immediate comment from the government but Yingluck's Puea Thai Party said the verdict was a loss for those who had exercised their right to vote.
"The vote was nullified because protesters stopped it from taking place across the country," spokesman Prompong Nopparit told Reuters.
Yingluck called the election in December to try to defuse the protests and since then has headed a caretaker government with limited powers. Puea Thai had been expected to win.
The court judges ruled in six to three votes that the February 2 election was unconstitutional because voting failed to take place on the same day around the country.