Taiwan's parliament has become the first in Asia to legalise same-sex marriage following a vote on Friday.
Parliament was given a two-year deadline and was required to pass the changes by 24 May.
Lawmakers debated three different bills to legalise same-sex unions - the government's bill - the most progressive of the three was passed.
Hundreds of gay rights supporters gathered in the rain outside the parliament building in the capital, Taipei, to await the landmark ruling.
There were shouts of joy and some tearful embraces as the result was announced.
What does the bill entail?
The two other bills, submitted by conservative lawmakers, refer to partnerships as "same-sex family relationships" or "same-sex unions" rather than "marriages".
But the government's bill, also the only one to offer limited adoption rights, was passed by 66 to 27 votes - backed by lawmakers from the majority Democratic Progressive Party.
It will take effect after Taiwan's President Tsai Ing-wen passes it into law.
Several same-sex activists had said ahead of the vote that this was the only version they would accept.
"The [government]'s bill is already our bottom line, we won't accept any more compromise," Jennifer Lu, the chief co-ordinator of rights group Marriage Equality Coalition Taiwan told Reuters news agency.
How did we get here?
In 2017, Taiwan's constitutional court ruled that same-sex couples had the right to legally marry.
It said then that the island had two years to make necessary changes to the law.
But this was met with a public backlash, which pressured the government into holding a series of referendums.
The referendum results showed that a majority of voters in Taiwan rejected legalising same-sex marriage, saying that the definition of marriage was the union of a man and woman.
However, conservative opponents were angered by the vote.
Tseng Hsien-ying, from the Coalition for the Happiness of Our Next Generation, told AFP news agency the vote had "trampled on Taiwanese people's expectations that a marriage and a family is formed by a man and a woman, a husband and a wife".