Taiwan's constitutional court has ruled that same-sex couples have the right to legally marry, the first such ruling in Asia.
The court, known as the Judicial Yuan, said current marriage laws violate the constitutional rights of same-sex couples and it gave a period of two years for laws to be amended to allow same-sex marriage.
Activists were optimistic the decision would go in their favour, with growing momentum behind the push for equal marriage rights on the island.
However there is also anger among conservative groups who have staged mass rallies against a change in the law as the debate divides society.
A panel of 14 grand justices made the ruling in a case that centres on whether Taiwan's current law is unconstitutional.
Taiwan's pioneering gay rights campaigner, 59-year-old Chi Chia-wei, is one of the petitioners who have brought the case to the constitutional court.
He urged the judges to allow gay couples to register to marry the next day if they approve a change in the law, rather than giving the government a longer time-frame to implement the decision.
At the heart of the case was a clause in Taiwan's Civil Code that an agreement to marry should be made between a man and a woman.
Mr Chi wanted the court to rule on whether that contravenes elements in Taiwan's constitution which guarantee equality and freedom of marriage.
The other party which brought the case is the Taipei city government, which has been rejecting marriage applications by same-sex couples and is seeking clarification of the law.
For the first time ever, the judiciary released the decision simultaneously in Chinese and English, an indication of the level of international interest.
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.
Taiwan is seen as one of the most progressive societies in Asia when it comes to gay rights, and momentum has been gathering since President Tsai Ing-wen, who has openly supported marriage equality, came to power a year ago.
However, as well as huge pro-gay marriage rallies, hundreds of thousands have gathered to demonstrate against legalising same-sex unions.
Conservative and religious groups in Taiwan say that it would destroy family values.