According to the country's Supreme Court, Kenyan authorities erred in forbidding the gay community from registering a rights organization.
But it also emphasized that gay sex is still illegal.
The National Gay and Lesbian Human Rights Commission (NGLHRC) was prevented from registering in 2013, according to a three-to-two decision by the judges.
The Supreme Court's decision is final because it is Kenya's highest court.
The judges determined that "it would be unconstitutional to limit the right to associate, through denial of registration of an association, solely on the basis of the applicants' sexual orientation" in their ruling.
For Kenya's gay community, the decision is nevertheless bittersweet. It is illegal to have sex that "is against the order of nature," according to laws that were implemented during British colonial rule. This offense carries a 14-year prison sentence.
A challenge to these laws was denied by Kenya's high court in May 2019.
Eric Gitari, the former executive director of the NGLHRC, challenged the head of the Kenya NGO Coordination Board's decision to deny him permission to apply to register an NGO under a name that contained the words gay or lesbian in 2013, which sparked the start of a 10-year legal battle that ended with Friday's decision.
His case was upheld by the judges at the High Court in 2015, the Court of Appeal in 2019, and finally the Supreme Court in 2023.
The Supreme Court's decision to uphold the decisions of the lower courts is a victory for justice and human rights, according to Njeri Gateru, the current executive director of the NGLHRC, who spoke after the decision.
"At a time when the LGBTIQ community in Kenya is protesting the rise in harassment and violence, this decision upholds the spirit and intent of the Constitution, which protects all Kenyans and ensures their rights. ".
The decision was made at a time when homophobic rhetoric has become more prevalent in Kenya.
Police harassment, body checks to "prove" gay sex, open insults on social media, and other forms of discrimination have all been directed at members of the LGBTQI community. For being gay, some claim they have even been denied access to healthcare and kicked out of rental properties.
On the day of the verdict, Member of Parliament George Peter Kaluma submitted a formal notice of his intention to introduce a bill that would sentence those found guilty of homosexuality or the promotion of it to life in prison.
The Supreme Court's decision on Friday may have rendered it impossible to pass new laws that would have made it legal to harass openly gay people, but Mr. Kaluma can still mobilize MPs to lengthen the sentences for gay sex.
Gay sex is also prohibited in Uganda, a neighboring country where Muslims hold Friday prayers that condemn it.
The prayers are held in the midst of a recent rise in homophobic sentiment in the nation.
The West should stop attempting to impose its beliefs and "normalize" what he called "deviations," according to President Yoweri Museveni, who stated last week that Uganda would not accept homosexuality.