Ugandan opposition leader Kizza Besigye has been found not guilty of rape by a court in the capital, Kampala.
Kizza Besigye said the charges disrupted his election challenge
The judge said the prosecution had been "crude and amateurish". Dr Besigye has always said the charges against him were politically motivated.
He still faces treason charges in the high court, and the army is pursuing him on terrorism and weapons charges.
Dr Besigye's lawyers have lodged a legal challenge to his recent election defeat to President Yoweri Museveni.
A higher court ruled the army had no jurisdiction to try a civilian on terror and weapons charges, but the state is appealing against that case, although in a slight u-turn, the prosecutor at the court martial has told the press that Dr Besigye has not been summoned.
"The state has dismally failed to prove its case against the accused," said Judge John Bosco Katutsi, delivering judgement in the rape case.
Dr Besigye said he was "very happy that another case of abuse of the legal process has been successfully disposed of".
"This case has had serious adverse affect on me, my family and the FDC party as indeed it was intended," he said after the judgement.
BESIGYE IN COURT
Treason: Trial to start 15 March
Terrorism: Army appealing against dismissal
Weapons offences: Army appealing against dismissal
Besigye to contest election results
Besigye may sue for wrongful arrest
"I intend to seek legal redress for the malicious prosecution - any compensation accruing from this process will be donated to women's organisations dedicated to fighting the abuse of women."
During the trial, the court heard that President Museveni himself had instructed the police to investigate the alleged 1997 rape.
It also heard that the alleged victim and a key witness were housed and looked after by the state for several years.
His treason trial is due to start on 15 March.
The authorities deny that the charges are political and insist they have evidence that Dr Besigye contacted rebel groups with a view to ousting Mr Museveni.
Dr Besigye's lawyers on Tuesday filed a petition challenging the results of last month's elections.
He says the polls were manipulated and many of his supporters were prevented from casting their ballots.
EU observers have not confirmed these complaints but did criticise Dr Besigye's arrest and incarceration after he announced he would stand.
President Museveni accuses Dr Besigye of working with rebels
Officials from the ruling National Resistance Movement have accused Dr Besigye and his supporters of being "bad losers".
Mr Museveni has ruled Uganda for 19 years and had been seen as part of a "new generation" of African leaders.
But he was criticised for changing the constitution to enable him to stand in this year's polls.
He received 59%, against 37% for Dr Besigye.
Dr Besigye used to be Mr Museveni's personal doctor and were allies in the guerrilla war which brought Mr Museveni to power but the pair fell out and were also election rivals in 2001.
After losing that poll, Dr Besigye fled Uganda, saying he feared for his life and only returned last year.