Tyrone Siu / Reuters Supporters react during a rally after Taiwan's constitutional court ruled that same-sex couples have the right to legally marry, the first such ruling in Asia, in Taipei, Taiwan May 24, 2017.

Taiwan’s constitutional court declared on Wednesday that same-sex couples have the right to legally marry, the first such ruling in Asia, sparking celebration by activists who have been campaigning for the right for years.

The court, known as the Judicial Yuan, said current marriage laws were “in violation of both the people’s freedom of marriage ... and the people’s right to equality”, and it gave two years for legal amendments to allow same-sex marriage.

“If relevant laws are not amended or enacted within the said two years, two persons of the same sex who intend to create the said permanent union shall be allowed to have their marriage registration effectuated,” the court said.

Lesbian, gay, bisexual and transgender rights activists had harbored high hopes their years of campaigning for same-sex marriage would win the court’s backing.

The ruling Democratic Progressive Party that swept national elections in the self-ruled island last year supported the change.

Hundreds of supporters of same-sex marriage gathered in the street next to the island’s parliament to celebrate the decision, holding colorful umbrellas to ward off a drizzle.

“This ruling has made me very happy,” said Chi Chia-wei, a veteran gay rights activist who had petitioned the court to take up the issue.

The ruling clearing the way for same-sex marriage is the first in Asia, where socially conservative attitudes largely hold sway.

Graphic on countries and regions that allow same-sex marriage: tmsnrt.rs/2rg66SW

A lawyer said the ruling made clear that same-sex couples had the same marriage rights as opposite-sex couples.

“This is a clear victory for equal rights in marriage and it is also a victory for all the people,” said Victoria Hsu, the lead lawyer supporting Chi’s case.

Taiwan has a reputation as a beacon of liberalism in the region.

“Sexual orientation is an immutable characteristic that is resistant to change,” the court said in its ruling.

“Furthermore, the freedom of marriage for two persons of the same sex, once legally recognized, will constitute the collective basis, together with opposite-sex marriage, for a stable society,” it said.

Taiwan, which China regards as a renegade province, has a celebrated annual gay pride parade that showcases the vibrancy of its lesbian, gay, bisexual and transgender community.

(Reporting by J.R. Wu; Editing by Robert Birsel)