The men belonged to a group set up to fight HIV and Aids
Senegal's court of appeal has quashed January's convictions of nine men for homosexuality and ordered their immediate release.
They were sentenced to eight years in jail after being found guilty of "indecent conduct and unnatural acts".
The men - who part of an anti-HIV/Aids group - were arrested in December at a flat in a suburb of the capital, Dakar.
Homosexual acts are illegal in Senegal, a predominantly Muslim country where gay people remain marginalised.
The defence team argued at the beginning of the appeal last week that the case against the men was based mainly on anonymous tip-offs, reported AFP news agency.
The accused were not caught in the act as the prosecution had suggested during the trial, argued the defence.
French President Nicolas Sarkozy had expressed his concern at the original verdict.
The sentences were the highest ever handed down in Senegal for a homosexuality conviction and sparked outrage from international gay rights groups.
In sentencing the nine, the judge added three years to a five-year sentence, saying the men were also members of a criminal group.
In February 2008, the editor of a magazine in Senegal received death threats after publishing pictures claiming to depict a wedding ceremony between two men.