Taiwan's High Court has rejected an opposition challenge that President Chen Shui-bian won March's presidential election unfairly.
President Chen was shot on the eve of voting
The court threw out opposition claims the poll was marred by irregularities and the election-eve shooting of Mr Chen, who won by just 30,000 votes.
The opposition claimed the shooting was staged to win Mr Chen votes, a claim the president has strongly denied.
The Kuomintang (KMT)-led opposition has 20 days to appeal against the ruling.
KMT lawyer Jaclyn Tsai said the High Court was biased towards the president.
"This case was directed at the most powerful person in Taiwan who abuses power and jeopardizes the fairness of
elections," Ms Tsai said, of President Chen.
But the president's lawyer, Wellington Koo, urged the KMT to accept the court's decision.
"Everybody must believe the judiciary is independent and that in this era there is
no black hand interfering in the judiciary," he told the Associated Press.
Thursday's hearing took place amid heavy security, with riot police guarding the court building from opposition supporters outside.
After seven months of hearings, ballot
recounts and investigations, Wu Ching-yuan, the High Court's presiding judge, announced that "the petition to nullify the
election result is rejected".
The March election was won by a razor-thin margin, and soon after the result was announced, losing candidate Lien Chan complained of alleged irregularities.
The resulting lawsuit was directed at President Chen himself.
It also accused him of staging his own shooting on the eve of election day, to win sympathy votes, and of taking advantage of the attack by putting the security forces on alert - claims Mr Chen's supporters strongly denied.
A second lawsuit, which is still being heard, alleges the election itself was illegal, because a referendum on security issues was held on the same day.