Kenya's high court refused to scrap laws criminalising homosexuality on Friday in a blow to the gay community that is set to ripple across a continent where homophobia is rife.
Gay rights organisations had hoped Kenya would follow in the footsteps of African nations like Angola, or those further afield like India, and end decades-old laws which criminalise gay sex.
But three years after they filed their petition, the high court ruled that the laws in question were not unconstitutional, leaning heavily on concerns about traditional culture and family values in Kenya.
"We find the impugned sections (of the penal code) are not unconstitutional. We hereby decline the relief sought and dismiss the consolidated petition," said Roselyne Aburili, presiding over a three-judge bench.
Inside the packed courtroom, gay couples held hands and waved rainbow flags as the lengthy judgement was read out.
After the ruling, they embraced and wiped away tears, and others wrapped themselves in flags.
"We have to fight for our rights. This is who we are," said Jordan Zeus, a gay Ugandan man who escaped persecution there to seek refuge in Kenya, urging activists to keep fighting.
In a remark prompting gasps, Aburili said there was "no conclusive scientific proof that LGBTQ people are born that way".
Campaigners had asked the court to scrap two sections of the penal code that criminalise homosexuality.
One section states that anyone who has "carnal knowledge... against the order of nature" can be imprisoned for 14 years.
Another provides for a five-year jail term for "indecent practices between males".
Petitioners argued these laws infringed on their privacy and dignity, fomented discrimination against homosexuals and prevented them from gaining access to healthcare and justice.
The court dismissed all of these arguments, saying the petitioners failed to provide sufficient evidence.
Aburili said that while rulings scrapping such laws around the world were "persuasive, they are not binding on this court".
A coalition of gay rights groups issued a statement expressing their "great distress" at the ruling, saying it "justifies the stigma, discrimination and violence meted against Kenyans" in the LGBT community.
Human Rights Watch said in a statement the decision was "a step backward in the progress Kenya has made toward equality in recent years."
The judges leaned heavily on section 45 subarticle 2 of the constitution, which states that "every adult has the right to marry a person of the opposite sex."
She said decriminalising sex between members of the same sex would "contradict the express provisions" of that part of the constitution.
Aburili said it did not matter that the petitioners were not seeking the right to same-sex marriage, as decriminalisation would lead to "same-sex persons living together as couples."
United Nations rights chief Michelle Bachelet urged LGBT activists and their allies to keep fighting for equality.
"Criminalizing acts targeting certain individuals based on who they are and whom they love is inherently discriminatory. It also sends a dangerous signal to broader society and encourages hostility and even violence against LGBT individuals," Bachelet said in a statement.
Outside the court, a Christian group sang choir songs and held aloft banners declaring "God forbids it and we say no!" as dejected members of the LGBT community streamed past.
"We are not here to speak hate, but we are saying no. And even at the court of appeal, we will still be standing as the church of Jesus Christ saying no," said Apostle Kathy Kageni, from the Sozo Church of God.
Friday's verdict had been awaited by activists across Africa.
Twenty-eight out of 49 countries in sub-Saharan Africa have laws penalising same-sex relationships, according to Neela Ghoshal, a Human Rights Watch (HRW) specialist in lesbian, gay, bisexual, and transgender rights.
The death penalty is on the books, under Islamic sharia law, in Mauritania, Sudan and northern Nigeria, although there have been no known executions in recent times. In southern Somalia, gay men are believed to have been put to death in territory ruled by the Al-Shabaab jihadist group.
Angola, Mozambique and Seychelles have scrapped anti-gay laws in recent years.
On the other hand, Chad and Uganda have introduced or toughened legislation.