Former South African Deputy President Jacob Zuma has been acquitted of raping a 31-year-old family friend.
Anti-rape protesters wore cloths to protest at defence arguments that such dress was "provocative"
There were jubilant scenes in central Johannesburg as Mr Zuma addressed the crowd, and accused the media of finding him guilty before the trial started.
Mr Zuma was once seen as a future president and remains popular, but analysts say evidence aired in the rape trial has badly damaged his reputation.
He still faces a separate charge of corruption, to be heard in July.
Delivering judgement, Judge Willem van der Merwe said the state had not proven the case beyond reasonable doubt.
He also referred to evidence given by the defence, suggesting that the complainant had a history of making false accusations of rape.
"The complainant was inclined to accuse men of raping her or attempting to rape her," the judge concluded.
Mr Zuma, who played a key role in the fight against apartheid, admitted having had sex with the woman, but insisted it was consensual.
Referring to their contradictory versions of the events of the night of 2 November 2005, the judge declared "the probabilities favour the accused's version".
He said Mr Zuma would not have risked forcing himself on the woman when his own daughter was in the house and police were on guard outside, who would have heard the accused if she had cried out.
South Africans give their views on the judgement
Because of public interest in the case, Judge van der Merwe allowed his four-hour ruling to be broadcast live on radio and television.
The judge began his ruling by expressing his regret that "some pressure groups and individuals found the accused guilty and some found him not guilty" while the trial was under way.
A significant police presence, along with rolls of razor wire and police trucks, had moved in to cordon off the court house overnight.
A crowd of several hundred supporters was present as proceedings began, but had grown to more than 1,000 by midday.
Women demonstrating against rape outside the court wore "kangas", or wrap-around cloths, in protest at the defence's argument that the complainant had provoked the sexual encounter by wearing such a cloth while a guest at Mr Zuma's house.
The One in Nine Campaign, which has headed a campaign in supporting the complainant and calling for reform of South Africa's sexual violence legislation, said it was "disappointed but not surprised by the verdict".
A statement by the group - whose name reflects that only one in nine rapes in South Africa is reported - said the complainant had been subjected to "a relentless and invasive cross-examination aimed at discrediting her as a witness".
Mr Zuma addressed the crowd in nearby Beyers Naude Square, with angry words for the media and political analysts who have criticised him.
"A person who is charged remains innocent until proven otherwise - this is one of the golden rules of our constitution but the press broke this rule," he said.
"Today the bad dreams have evaporated."
While deputy president, Mr Zuma was also head of South Africa's National Aids Council and the Moral Regeneration Movement.
His views on HIV prevention, which were aired in court, have shocked Aids activists.
Support at the grassroots has been strong for Zuma the politician
Mr Zuma said he had had a shower after sex to prevent HIV transmission and believed that a healthy man was unlikely to catch HIV from a woman.
Judge van der Merwe said such behaviour was "totally unacceptable".
"This trial has really damaged his reputation, his credibility," political analyst William Mervin Gumede told the BBC's Focus on Africa programme.
In July, he faces another trial on the corruption charges that led to his dismissal as deputy president last year. He denies the charges.