The court said that if parliament does not make the change within 2 years, same-sex couples could register to marry regardless.
Taipei: Taiwan's top court ruled in favour of gay marriage Wednesday, a landmark decision that paves the way for the island to become the first place in Asia to legalise same-sex unions.
Crowds of supporters cheered, hugged and wept as the court said that current laws preventing the practice "violated" the constitution's guarantees of freedom of marriage and equality. It gave the government two years to implement the ruling.
Momentum has been growing behind the push for equal marriage rights, with Taiwan's president Tsai Ing-wen openly supporting the campaign.
But there has also been anger among conservative groups, who have staged mass rallies against any change in the law.
The constitutional court said that if parliament does not make the change within two years, 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," it said in a statement.
The decision to allow gay marriage would contribute to social stability and protect "human dignity" it added.
Hundreds of gay marriage supporters who had gathered outside parliament in central Taipei erupted at the news, with some breaking down in tears.
Activists addressing the crowd said they must now fight to ensure the government implements the ruling.
"I hope the law can pass by the end of the year," said Bubu Chen, who had an unofficial marriage ceremony with his partner in 2013.
Some campaigners fear that opposing voices in parliament may try to delay the process of changing the law.
Outside Taipei's main judicial headquarters, angry anti-gay marriage protesters beat drums shouting "unfair justice" and "sinners", calling for the head of the judiciary to step down.
A panel of 14 grand justices made the ruling -- a majority of 10 was needed. Only two judges dissented.
The court said the physical and psychological need for permanent unions was "equally essential to homosexuals and heterosexuals, given the importance of the freedom of marriage to the sound development of personality and safeguarding of human dignity".
Taiwan's pioneering gay rights campaigner, Chi Chia-wei, was one of the petitioners who brought the case to the constitutional court, culminating some 30 years of activism.
The other petitioner in the case was the Taipei city government, which has been rejecting marriage applications by same-sex couples and is seeking clarification of the law.
The ruling is likely to reverberate around the region, with calls for marriage equality rising in a number of countries, including South Korea and Japan.