LGBTQ rights took a big leap forward in Lebanon on Thursday after a top court ruled that homosexuality is legal under the country’s criminal code.

Gay sex is punishable by up to a year in prison under Article 534 of the Lebanese Penal Code. A holdover from French occupation, the colonial-era law claims that same-sex relationships “contradict the laws of nature.” Although defenders claim it is rarely enforced, nine people challenged the law in court after being targeted under the law.

In last week’s ruling, the Penal Appeal Court in Mount Lebanon claimed authorities “had not intended to criminalize homosexuality but rather offense to public morals.”

The appeals court decision served to uphold a lower court ruling dismissing charges against the petitioners. Last January, Metn Judge Rabih Maalouf claimed that queer and trans people are guaranteed “a practice of their fundamental rights” under Article 183, which states that actions “undertaken in exercise of a right without abuse shall not be regarded as an offense.”

Three other Lebanon courts have ruled in favor of LGBTQ rights in recent years.

Back in 2011, Judge Mounir Soliman paved the way for the appeals court’s decision by ruling that gay sex should not be considered “unnatural” under the vaguely worded penal code. Five years later, Jdeide Court Judge Naji El Dahdah tossed out charges against a transgender woman prosecuted for having sex with a man.

While advocates are calling for Article 534 to be formally stricken from the penal code, Legal Agenda attorney Karim Nammour told PinkNews the ruling “could have repercussions on the way that lower court judges rule.”

“The appeals court has a certain authority,” Nammour said. “It’s higher in the hierarchy.”

A legal shift in how the Lebanon court system regards LGBTQ rights could have a huge impact on the country’s queer and trans population, who have long been persecuted via Article 534. Police frequently use the law as a pretext to search the phones of gay men, looking for incriminating texts and photos or the presence of hookup apps.

The penal code has led to a series of raids against bathhouses and movie theaters, resulting in dozens of arrests and human rights abuses.

After authorities rounded up 36 people at Beirut’s once-popular porn theater Plaza Cinema in 2014, the detainees were subjected to forced anal exams to “determine” their homosexuality. These tests have been condemned by leading organizations from the United Nations to Amnesty International, who have likened the practice to “torture” and called to ban its use.

Following an onslaught of arrests at various checkpoints around Lebanon in 2016, a transgender woman was beaten, spat on, and tied to a chair by police officers who allegedly attempted to force her to have sex with them.

But recent years have given reason to hope the situation is improving in the Middle Eastern country, widely viewed as more tolerant than its neighbors.

A historic number of candidates came out in favor of LGBTQ rights during the May 6 elections, Lebanon’s first democratic vote in nearly a decade. According to CNN, around 100 politicians voiced their support for queer and trans equality–although many of those office seekers were independents with little chance of winning their races.

Earlier in the year, the Christian Democratic Kataeb advocated for the removal of Article 534 as part of a 131-point plan. The decision, which was announced live on TV, was the first time a political party spoke out in favor of LGBTQ rights as part of its platform.

Challenges to progress will remain, however. Eighty-percent of Lebanese citizens say homosexuality should not be accepted by society, while the government cracks down on Pride events. After Lebanon became the first Arab country to hold a pro-LGBTQ parade in 2017, authorities shut down Beirut Pride Week earlier this year.

Image via Getty