Hong Kong’s government will have to set up a new legal framework to recognize same-sex marriage registered overseas, its top court ruled Tuesday, ending a five-year legal battle. The decision is the latest in a series of cases in recent years that have pushed the city towards accepting the LGBTQ+ community.

In the landmark court ruling, a majority of the judges at the city's Court of Final Appeal declared the government is in violation of its obligation to legally recognize same-sex partnerships and would have to do so to dispel "any sense that they belong to an inferior class of persons whose relationship is undeserving of recognition." The court gave the government two years to comply or submit a new rule.

Same-sex couples in Hong Kong need "access to an alternative legal framework in order to meet basic social requirements," Justice Patrick Keane wrote in a decision also signed by Chief Justice Andrew Cheung, and Justices Roberto Ribeiro, Joseph Fok, and Johnson Lam. 

The justices added: "The absence of legal recognition of their relationship is apt to disrupt and demean their private lives together in ways that constitute arbitrary interference."

HONG KONG COURT REFUSES TO BAN PROTEST SONG, GOVERNMENT NOW ALLOWED TO APPEAL DECISION

A photo of Hong Kong's top court

Hong Kong's top court on Sept. 5 ruled in favor of same-sex partnerships including civil unions, though it stopped short of granting full marriage rights in a partial win for the city's LGBTQ+ community.  (PETER PARKS/AFP via Getty Images)

Currently, Hong Kong only recognizes same-sex marriage for select purposes including taxation, civil service benefits and dependent visas. Most of these concessions were recently adopted as Hong Kong, which officially operates as a special administrative state under Chinese rule, has seen a growing social acceptance of same-sex marriage.

The case was prompted by Jimmy Sham, a prominent activist in the city, who married his husband in New York in 2013. Sham has repeatedly requested a judicial review of Hong Kong's laws pertaining to same-sex marriage, most of which have failed. 

In 2018, he began arguing Hong Kong’s refusal to accept same-sex marriage legitimized by a foreign government was in violation of the constitutional right to equality. The lower courts had dismissed his challenges.

HONG KONG ARRESTS 10 FOR THEIR ALLEGED INVOLVEMENT IN OVERSEAS DONATIONS MEANT TO SUPPORT FLEEING DISSIDENTS

Jimmy Sham

Detained activist Jimmy Sham, center, leaves a prison van to enter the Court of Final Appeal as Hong Kong's top court hears the activist's last bid to ask for recognition of his New York-registered same-sex marriage. (AP Photo/Louise Delmotte)

Sham, a 36-year-old former convenor of Civil Human Rights Front, has been in custody since March 2021 following a protest where nearly 50 people were charged under a Beijing-imposed national security law.

CLICK HERE TO GET THE FOX NEWS APP

Esther Leung, the campaign manager of the Hong Kong Marriage Equality group, called the decision a "major step forward" but said, "it falls short of what is really at stake in this case: full inclusion in marriage," according to Reuters.

A photo of Hong Kong, buildings

Jimmy Sham partially won his final appeal in Hong Kong Tuesday, Sept. 5, 2023, seeking recognition for same-sex marriage registered overseas. (Anthony Kwan/Getty Images)

The court’s ruling was only a partial win for Sham as the justices unanimously dismissed his appeal on other grounds. They also reaffirmed Hong Kong's mini-constitution, called the Basic Law, only formally recognized heterosexual marriage.

The ruling will likely have a major impact on the city’s social acceptance of LGBTQ+ relationships.

The Associated Press contributed to this report.