Ukraine's Supreme Court has annulled the second round of the presidential election - upholding opposition claims that it was fraudulent.
Opposition supporters were jubilant
It ruled that a new run-off vote must be held by 26 December.
In the capital Kiev, supporters of pro-Western candidate Viktor Yushchenko cheered as the verdict was announced.
But aides to his rival who had been declared winner, pro-Moscow Prime Minister Viktor Yanukovych, said the court had played a "political role".
His supporters in the eastern city of Donetsk were angry at the verdict and vowed to vote for Mr Yanukovych again.
The original 21 November run-off had been criticised by Western observers over what they said were numerous irregularities.
The prime minister and his patron, outgoing President Leonid Kuchma, had pressed for a completely new election - possibly with a new government candidate.
But Mr Yushchenko wanted - and got - a re-run of the second round only, possibly enabling him to capitalise on the momentum he has built up, with thousands of his supporters thronging the streets of the capital for two weeks.
He told them to keep up their protest - and urged President Kuchma to sack the prime minister and the country's election commission.
Both sides in the conflict have said they will abide by the court's decision.
The Supreme Court said it had found that the results of the 21 November poll were marked by numerous violations which the central election commission had failed to examine.
"The actions and decisions of the central election commission concerning the results of the run-off presidential vote were unlawful," Judge Anatoly Yarema said.
Tens of thousands of opposition protesters who had converged on Kiev's central square to await the verdict cheered at the outcome, waving blue-and-yellow Ukrainian flags and orange opposition flags, and chanting "Yushchenko! Yushchenko!".
"Today Ukraine has turned to justice, democracy and freedom," Mr Yushchenko told the jubilant crowd.
"I would like to ask you today to specially applaud the judges of the Supreme Court. They are the true heroes today."
The Yanukovych camp condemned the court for playing "a political role".
The court "even went beyond the plaintiff's appeal... [that] did
not ask for another run-off vote, but had asked to annul results,"
Interfax news agency quoted Stepan Havrysh, a Yanukovych aide, as saying.
'In line with the truth'
The president of Ukraine's western neighbour, Poland, Aleksander Kwasniewski, welcomed the ruling which he said was "in line with the truth and with the will of the people, creating a chance to quickly end the political crisis".
The European Union, which had criticised the original run-off poll, also hailed the ruling.
"I urge all parties to work constructively for a rapid, just and transparent outcome," said External Affairs Commissioner Benita Ferrero-Waldner.
The judges had been pondering the case all week
In the US, White House spokesman Scott McClellan said: "The court's decision is an important step in moving toward a peaceful, democratic resolution that reflects the will of the people."
President Vladimir Putin of Russia had backed calls for an entirely fresh poll to pre-empt further challenges and re-runs.
Mr Putin has also expressed concern about a possible split between the west of Ukraine, which generally supports Mr Yushchenko, and the east, which tends to lean towards Russia.