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 and the government's bill, the most progressive of the three, was passed.
Thousands 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.
However, conservative opponents were angered by the vote.
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.
"I'm very surprised - but also very happy. It's a very important moment in my life," Jennifer Lu, chief co-ordinator of rights group Marriage Equality Coalition Taiwan, told the BBC.
"However, it's still not full marriage rights; we still need to fight for co-adoption rights, and we are not sure about foreigner and Taiwanese marriage, and also gender equality education.
"It's a very important moment, but we are going to keep on fighting. We are Taiwanese and we want this important value for our country, for our future," she added.
"For me the outcome today is not 100 percent perfect, but it's still pretty good for the gay community as it provides legal definition," said Elias Tseng, a gay pastor who spoke to the AFP news agency outside parliament.
Taiwanese singer Jolin Tsai posted a picture of a rainbow on Facebook accompanied by the caption "Congratulations!! Everyone deserves happiness!"