Gay rights supporters in Taiwan are celebrating today after the Constitutional Court said banning same-sex marriage is unconstitutional.

A top Taiwan court ruled in favor of gay marriage, in a landmark ruling that paves the way for the country to become the first place in Asia to legalize same-sex unions.

The court said Taiwan's current Civil Code, which says an agreement to marry could only be made between a man and a woman, "violated" the constitution's guarantees of freedom of marriage and people's equality.

It gave Taiwan's government two years to implement the ruling.

If parliament does not make the change within two years, the court said same-sex couples could register to marry regardless, based on its interpretation.

"The current provisions of the marriage chapter do not allow two persons of the same sex to create a permanent union of an intimate and exclusive nature for the committed purpose of managing a life together. This is obviously a gross legislative flaw," a statement from the court said.

The push for equal marriage rights has gathered momentum in Taiwan with hundreds of thousands rallying in support.

But there has also been anger among conservative groups, who have staged mass protests against any change in the law.

The court ruled that the decision to allow gay marriage would contribute to social stability and protect "human dignity."

Supporters from both camps had gathered in central Taipei to await the decision, with hundreds of pro-gay marriage campaigners flying rainbow flags outside parliament.

A panel of 14 grand justices made the ruling. A majority of 10 was needed. Only two judges dissented.

Chi Chia-wei's battle

The Constitutional Court, also known as the Council of Grand Justices, began public hearings on March 24, after cases were brought to the court by long-time LGBT rights activist Chi Chia-wei (祁家威) and the Taipei City Government.

Chi petitioned for the case to be heard when his attempt to register his marriage with his partner in 2013 was rejected. The Taipei City government presented a petition due to growing requests for same-sex marriage.

The hearing saw supporters and opponents debate whether Taiwan's Civil Code allows same-sex marriage. Currently, Article 972 of the Civil Code states, “An agreement to marry shall be made by the male and the female parties in their own [con]cord.” Proponents of same-sex marriage argue that this article does not limit marriage to one male and one female.

For the pioneering gay rights campaigner, Chi Chia-wei, today was the culmination of 30 years of activism.

"I'm leaping with joy like a bird," Chi, 59, told AFP.

"I hope parliament will prioritize the bill instead of dragging it on for another two years," he added.

The other petitioner was the Taipei city government, which has been rejecting marriage applications by same-sex couples and was seeking clarification of the law.

At the rally, Uther Wu, 40, said the ruling was "like a cloud being blown away".

Others felt it would put Taiwan on the map.

"This will open doors for a lot of other countries in the region," said Toby Chang, 28, at the rally.

"It's also good for Taiwan. It will bring a lot of international attention and recognition," he added.

Calls for marriage equality are gaining strength in a number of countries around Asia, including South Korea and Japan.

[UPDATES TO FOLLOW]

A timeline of the struggle for same-sex marriage in Taiwan:

1986: Chi Chia-wei requests notarized marriage between two males. He is the first person in Taiwan to call for the legalization of same-sex marriage in Taiwan, and his request is denied by the government.

1996: Author Hsu Yu-sheng (許佑生) and his Uruguayan partner Gray Harriman hold Taiwan’s first public gay wedding ceremony.

2000: Chi Chia-wei requests a constitutional interpretation on same-sex marriage, but is rejected by the Grand Justices.

2006: Democratic Progressive Party legislator Hsiao Bi-khim (蕭美琴) proposes a same-sex marriage law, but it does not pass the first reading.

2011: Gay rights activist Nelson Chen (陳敬學) and his partner Kao Chih-wei (高治瑋) filed an administrative lawsuit for official recognition of their marriage at the Taipei High Court. They withdrew the suit in January 2013.

2013: The Taiwan Alliance to Promote Partnership Rights drafts a marriage equality bill, a civil partnership bill, and a family bill. The bills passed a first reading in October. The bill stalls after protests from anti-LGBT groups.

2014: The Legislative Yuan’s Judiciary and Organic Laws and Statutes Committee reviews the marriage equality bill, the first time in Asia a marriage equality bill is heard at a parliament. However, the review ends with no clear conclusion.

October 2016: Jacques Picoux, a French professor at the National Taiwan University commits suicide, sparking renewed interest in LGBT rights in Taiwan.

November 2016: Draft amendments to the Civil Code to allow same-sex marriage proposed by DPP legislator Yu Mei-nu (尤美女) pass the first reading at the Legislative Yuan.

December 2016: Legislator Yu Mei-nu’s draft amendments pass a review by the Legislative Yuan’s Judiciary and Organic Laws and Statutes Committee, making it the first same-sex marriage bill to pass reviews at the Legislative Yuan.

March 24, 2017: Taiwan’s Constitutional Court holds a hearing to debate the constitutionality of the Civil Code.

Constitutional Court verdict announced.

Homosexuality around the world: from the death penalty to gay marriage

Same-sex marriage, which Taiwan could become the first Asian nation to authorize, is currently legal in around 20 countries around the world, 13 of which are in Europe.

Such unions are, however, still illegal in most parts of Africa and in the Middle East, where homosexuality is in some cases punishable by the death penalty.

European pioneers

The Netherlands in April 2001 became the first country in the world to allow gay and lesbian couples to marry in a civil ceremony.

Twelve European countries followed: Belgium, Britain (except Northern Ireland), Denmark, Finland, France, Iceland, Ireland, Luxembourg, Norway, Portugal, Spain, and Sweden.

Some European countries only allow homosexuals to enter into civil partnerships, including Austria, Croatia, Germany, Greece, Hungary, Italy and the Czech Republic.

Estonia became in October 2014 the first former Soviet republic to authorize this kind of civil union.

Many eastern European countries - including Bulgaria, Latvia, Lithuania, Poland, Romania and Slovakia - still deny homosexuals the right to marry or enter into unions.

Slovenians in December 2015 voted in a referendum against efforts by their national parliament to legalized gay marriage.

Some 15 western European countries allow same-sex couples to adopt children, whether within marriage or civil partnership. They include

Belgium, Britain, Denmark, France, the Netherlands, Spain, and Sweden. Others like Finland, Germany and Slovenia allow gay people to adopt the child of their partner.

Ten countries allow lesbian couples to conceive children with the help of assisted reproductive technologies (ART): Austria, Belgium, Britain, the Netherlands, Spain and the Nordic countries.

Surrogacy remains restricted across most of the continent.

Belgium, Britain and the Netherlands allow for volunteer surrogacy and in Greece, women can be reimbursed for the costs of carrying a child for someone else.

Progress in America

Canada led the way in North America, authorizing same-sex marriage and adoptions in June 2005. ART and surrogacy are also allowed.

In the United States, with gay marriages still banned in 14 of the 50 states, a historic Supreme Court decision in June 2015 legalized gay marriage nationwide.

Mexico's federal capital led the way in Latin America towards civil unions in 2007 and full marriages in 2009.

Same-sex marriages are also legal in Argentina, Uruguay, Brazil and Colombia.

A crime in Africa

On a continent where around 30 countries ban homosexuality, South Africa is the only country on the continent where gays can legally marry and

adopt and have children by ART and surrogacy, since 2006.

In Sudan, Somalia and Mauritania homosexuals face the death penalty, while only a handful of countries -- Gabon, Ivory Coast, Chad, the

Democratic Republic of Congo, Mali, and Mozambique have decriminalized the practice.

Hostility in Middle-East, Asia

Israel leads the Middle East region in terms of respect for homosexual rights, and recognizes gay marriages performed elsewhere, though such

marriages are not performed in Israel itself. Gay couples can jointly adopt children.

Homosexuality is theoretically punishable by death in Saudi Arabia and the United Arab Emirates, while Lebanon is more tolerant than other Arab countries.

In Asia, after Taiwan, the taboo surrounding homosexuality is slowly eroding in Vietnam and Nepal.

Asia Pacific

The only country in the region that allows gays to marry is New Zealand, which passed a law in April 2013, 27 years after homosexuality was decriminalized.

The most recent attempt to legalized gay marriage in Australia hinged on a planned referendum that was blocked in November 2016.

Additional reporting by The News Lens.