(CNN) Lawmakers in Taiwan have approved a bill legalizing same-sex marriage, a landmark decision that makes the self-ruled island the first place in Asia to pass gay marriage legislation.

The vote came almost two years after the island's Constitutional Court ruled that the existing law -- which said marriage was between a man and a woman -- was unconstitutional. The panel of judges gave the island's parliament two years to amend or enact new laws.

On Friday -- only a week off the two-year deadline -- lawmakers in Taiwan's Legislative Yuan passed a bill making same-sex marriage a reality. It will go into effect on May 24.

In pictures: Taiwan becomes first in Asia to legalise same-sex marriages

Photos: In pictures: Taiwan becomes first in Asia to legalise same-sex marriages

People lined the streets outside the parliamentary administration building on Friday.

People lined the streets outside the parliamentary administration building on Friday.

In pictures: Taiwan becomes first in Asia to legalise same-sex marriages

Photos: In pictures: Taiwan becomes first in Asia to legalise same-sex marriages

LGBT rights protesters demonstrate as politicians continued to discuss the same-sex marriage bill ahead of Friday's vote.

LGBT rights protesters demonstrate as politicians continued to discuss the same-sex marriage bill ahead of Friday's vote.

In pictures: Taiwan becomes first in Asia to legalise same-sex marriages

Photos: In pictures: Taiwan becomes first in Asia to legalise same-sex marriages

So far nearly 300 gay and lesbian couples have applied to register for legal union on the day the bill is to come into effect.

So far nearly 300 gay and lesbian couples have applied to register for legal union on the day the bill is to come into effect.

In pictures: Taiwan becomes first in Asia to legalise same-sex marriages

Photos: In pictures: Taiwan becomes first in Asia to legalise same-sex marriages

Supporters of same-sex marriage gather outside as parliamentarians debated in Taipei, Taiwan, on Friday.

Supporters of same-sex marriage gather outside as parliamentarians debated in Taipei, Taiwan, on Friday.

In pictures: Taiwan becomes first in Asia to legalise same-sex marriages

Photos: In pictures: Taiwan becomes first in Asia to legalise same-sex marriages

A supporter stands outside the parliament building as the debate over the three draft bills of the same-sex marriage law continued inside. debate the three draft bills for marriage equality on Friday.

A supporter stands outside the parliament building as the debate over the three draft bills of the same-sex marriage law continued inside. debate the three draft bills for marriage equality on Friday.

In pictures: Taiwan becomes first in Asia to legalise same-sex marriages

Photos: In pictures: Taiwan becomes first in Asia to legalise same-sex marriages

Same-sex marriage supporters gather outside the Legislative Yuan in Taipei, Taiwan. The signs read, ''Vote Can't Be Defeated.''

Same-sex marriage supporters gather outside the Legislative Yuan in Taipei, Taiwan. The signs read, ''Vote Can't Be Defeated.''

In pictures: Taiwan becomes first in Asia to legalise same-sex marriages

Photos: In pictures: Taiwan becomes first in Asia to legalise same-sex marriages

A same-sex marriage supporter holds a rose to mourn those who have killed themselves because of discrimination.

A same-sex marriage supporter holds a rose to mourn those who have killed themselves because of discrimination.

In pictures: Taiwan becomes first in Asia to legalise same-sex marriages

Photos: In pictures: Taiwan becomes first in Asia to legalise same-sex marriages

Gay rights supporters wait in the rain outside the parliament building in Taipei before the landmark decision was announced on Friday.

Gay rights supporters wait in the rain outside the parliament building in Taipei before the landmark decision was announced on Friday.

In pictures: Taiwan becomes first in Asia to legalise same-sex marriages

Photos: In pictures: Taiwan becomes first in Asia to legalise same-sex marriages

Same-sex marriage supporters shout during a parliament vote on three draft bills of a same-sex marriage law, outside the Legislative Yuan in Taipei, on Friday.

Same-sex marriage supporters shout during a parliament vote on three draft bills of a same-sex marriage law, outside the Legislative Yuan in Taipei, on Friday.

In pictures: Taiwan becomes first in Asia to legalise same-sex marriages

Photos: In pictures: Taiwan becomes first in Asia to legalise same-sex marriages

Although the island has a large gay community and its annual gay pride parade is the biggest in Asia, the issue of marriage equality has bitterly divided Taiwanese society. In a controversial referendum in November last year, 67% voted to reject same-sex marriage.

In recent months conservative groups have campaigned against same-sex marriage reform, pushing for a law that would see gay marriages redefined as something closer to same-sex unions.

Tens of thousands of people braved pouring rain Friday to demonstrate in favor of same-sex marriage outside the parliament, as lawmakers began voting on three draft bills, one tabled by the island's Cabinet -- which would ultimately prove successful -- and two watered-down rival bills tabled by conservative groups.

The successful Cabinet bill was the only one to use the word "marriage." It was backed by LGBTQ groups, despite the fact it could see same-sex couples denied rights enjoyed by hetrosexual couples, such as adoption and cross-national marriage.

Wu Tzu-an, a 33-year-old gay artist from Taipei, was among the crowds outside the parliament celebrating Friday.

"Today the result was the best we got for this stage," said Wu. "It's also a sign to show that Taiwan was different from China," he added, referring to mainland China where same-sex marriage has not been legalized. "Personally I don't have plans to get married, but I think it's a sign for equality."

On May 17th, 2019 in #Taiwan, #LoveWon. We took a big step towards true equality, and made Taiwan a better country. 🏳️‍🌈 — 蔡英文 Tsai Ing-wen (@iingwen) May 17, 2019

Xiaogang Wei, who heads the Beijing Gender Health Education Institute, called the bill's passing a historic moment, not only for Asia but for the global LGBTQ rights movement.

"It will have a very positive impact on China's LGBT community, offering us a lot of hope," he told CNN.

"The Chinese government has pointed to cultural tradition as a reason for same-sex marriage being unsuitable in China. But the decision in Taiwan, which shares a cultural tradition with us, proves that Chinese culture can be open, diverse and progressive."

After the vote, Taiwan's President Tsai Ing-wen tweeted: "We took a big step towards true equality, and made Taiwan a better country."

Longtime struggle

Friday's decision has been a long time in the making.

In 2015, veteran gay rights activist Chi Chia-wei -- who has spent 30 years fighting for marriage equality -- filed a request to the Constitutional Court asking for a ruling on an article in the island's civil code stating that marriage is between a man and a woman.

The Taipei city government filed a similar request the same year after three same-sex couples lodged an administrative lawsuit against the government when their marriage registrations were rejected, CNA reported

BREAKING: Legislators just passed article 4, which means #Taiwan just legalized same-sex marriage and will be implemented on May 24th#First in #Asia#LGBT #LoveWins pic.twitter.com/FDjWNBAxru — Equal Love Taiwan (@equallovetw) May 17, 2019

In 2017, the court ruled the law violated the constitution.

Lawmakers were given a two-year deadline, but reached a deadlock. Taiwan's gay marriage opponents seized the opportunity to put forward a referendum asking voters whether they agreed with same-sex marriage.

Taiwan Alliance to Promote Civil Partnership Rights executive director Victoria Hsu, who represented Chi during his case, said she expected attitudes towards LGBTQ people to improve after the bill as they would see that heterosexual families "wouldn't lose anything."

But Hsu -- who plans to register her marriage with her partner of six years when the bill takes effect next Friday -- said more still needed to be done to make LGBTQ people truly equal.

"The fight is not over, but we will continue from this brand-new start," she added.

Amnesty International Taiwan's acting director Annie Huang agreed, saying: "The Taiwanese government must not stop here. It needs to act to eliminate all forms of discrimination on the grounds of sexual orientation, gender identities and intersex status."

LGBTQ rights in Asia

Taiwan's vote sets it apart from other parts of Asia where LGBTQ rights have regressed.

In mainland China, where homosexuality is legal but prejudices and discrimination against LGBT people persist under Communist Party rule, an author of same-sex erotic fiction was sent to jail for 10 years in November.

In April, the ruler of the tiny, oil-rich kingdom of Brunei announced he would introduce death by stoning for those convicted of gay sex . Sultan Hassanal Bolkiah has since said the death penalty will not be imposed, although he did not repeal the law.

In Indonesia, declining secularism has led to deepening discrimination against the country's gay, lesbian and transgender communities. Last year, two men accused of being gay received 87 lashes for gay sex in the country's conservative Aceh province.

More than two dozen countries around the world allow gay marriage, according to Pew Research.

Update: This story has been updated to reflect Taiwan's status