The gay community is estimated by activists to number 500,000 in Uganda
A Ugandan judge has awarded two women $7,000 (£4,700), saying their rights were infringed when they were arrested on suspicion of being lesbians in 2005.
One of them was undressed by police to prove she was a woman and assaulted.
"The verdict is welcomed with excitement by the gay community," activist Kasha Jacqueline told the BBC.
"It is a Christmas surprise for us," she said, adding that the judge had stressed such treatment was wrong. Homosexual acts are illegal in Uganda.
The case is believed to be the first time homosexuals have taken the police to court in Uganda, where they face much discrimination.
Activists say the gay community numbers about 500,000, from a population of some 31 million.
Ms Jacqueline heads Freedom and Roam Uganda (Farug), an organisation for lesbians and bisexuals.
We are proud to be Ugandan and that justice prevailed
Farug's Kasha Jacqueline
She said the two lesbians who brought the case against the government - Yvonne Oyoo and Victor Juliet Mukasa - were not in court to hear about their victory.
The verdict had been expected in mid-2007 and in the intervening 17 months the gay community had lost hope of getting a ruling, she said.
"It's been a long wait... but we are proud to be Ugandan and that justice prevailed," Ms Jacqueline told the BBC News website.
According to Ms Jacqueline, Justice Stella Arach-Amoko awarded $5,000 to Ms Oyoo, who had been a guest in Ms Mukasa's house when it was raided by police.
The payout was for "arbitrary torture", as Ms Oyoo had been man-handled and sexually assaulted, Ms Jacqueline said.
About $2,000 was awarded to Ms Mukasa, a leading Ugandan human rights activist, for damage to her house during the raid.
In an interview with the New Internationalist in 2007, Ms Mukasa said she decided to sue the government because she was tired of the harassment.
"It will be the first case of its kind in Uganda where LGBTs [lesbian, gay, bisexual and transgender people] are the ones suing the government," she said.
"I am suing because of the constant human rights violations that are committed against LGBT people by the government and the public of Uganda without anyone raising a hand."