A court in Egypt has cleared 26 men arrested last month in a raid on a bathhouse in Cairo and charged with "inciting debauchery".
Their trial had been seen as part of a campaign by the Egyptian authorities against the country's homosexuals.
Footage broadcast by a local TV station of the men being pulled half-naked out of the bathhouse by police outraged activists and rights groups.
Egyptian law does not criminalise homosexual acts, but they remain taboo.
Adults suspected of engaging in consensual homosexual conduct are frequently arrested on charges of debauchery, immorality or blasphemy.
'God rescued us'
The defendants acquitted on Monday covered their faces with jumpers or hats as they were marched into the courtroom in Cairo for the verdict.
Five of them - the owner of the bathhouse and four staff members - were tried for facilitating "parties of debauchery, orgies among male homosexuals" in exchange for money. The 21 others were charged with practising debauchery and "indecent public acts".
Analysis: John McManus, social affairs reporter, BBC News
It is not illegal to be homosexual or engage in homosexual acts in Egypt. But the International Lesbian, Gay, Bisexual, Trans and Intersex Association (ILGA) says the charge of "debauchery" is often used to crack down on homosexual activity in the country.
The charge is more often used in cases involving prostitution, but Egyptian legislation - specifically Law 10 of 1961, On the Combat of Prostitution - mentions "prostitution" and "debauchery" together.
The Collins English Dictionary defines the world as "an instance of extreme dissipation"; other descriptions relate to "sensual pleasures".
Homosexuality remains a social and religious taboo within Egypt. However, the country is not the only place where, while not illegal, it is punished or discouraged using other laws.
When the judge announced that they were all innocent, there were shouts of joy from their families.
"They destroyed our lives. God rescued us," one of the defendants, who would not give his name, was quoted as saying by the Associated Press.
One of the defence lawyers, Tarik al-Awadi, said: "The verdict is an accurate reflection of the law and we expected this outcome.
"However, the rights of the defendants will only be realised when [the authorities] put on trial the people who were involved in this, and who offended the honour of these people."
Several of the men have said they plan to pursue legal action against the Egyptian TV presenter, Mona al-Iraqi, who claimed she triggered the raid on the bathhouse on 7 December by tipping off the police about what was happening there. Days later, she broadcast footage that she said revealed "a den of mass perversion spreading Aids in Egypt".
Lawyers also said that at least one of the defendants was raped while in police custody, according to the Daily Telegraph's Louisa Loveluck.
The acquittal came less than a month after an appeals court reduced the prison sentences given to eight men convicted of "inciting debauchery" for appearing in a video allegedly showing a gay marriage.
Activists say the Egyptian authorities have launched a crackdown on the country's gay community over the past 18 months.
During that time, at least 150 men have been arrested or put on trial on debauchery charges, according to the Cairo-based Egyptian Initiative for Personal Rights.