Thailand's Senate has passed the final reading of a marriage equality law, paving the way for the country to become the third territory in Asia to recognise same-sex couples after Nepal and Taiwan.
The law gained the support of nearly all upper house MPs and will be sent to the palace for royal approval.
The law will come into force 120 days after it is published in the royal gazette.
LGBTQ+ advocates called the move a "monumental step forward" as it would make Thailand the first country in Southeast Asia to enact marriage equality legislation.
Thailand is already known for its vibrant LGBTQ+ culture and tolerance, making it a popular destination for tourists.
"This would underscore Thailand's leadership in the region in promoting human rights and gender equality," the Civil Society Commission of marriage equality, activists and LGBTI+ couples said.
The bill is the culmination more than a decade of effort from activists and politicians, after previous drafts did not reach the parliament.
At the start of June, thousands of LGBTQ+ revellers and activists held a parade through the streets of Bangkok and were joined by Prime Minister Srettha Thavisin, who wore a rainbow shirt to celebrate Pride Month.
Thai politicians have met to vote on legalising same-sex marriage, putting the kingdom on the cusp of becoming the first southeast Asian nation to recognise marriage equality.
"Today is the day that Thai people will smile. It is a victory for the people," Tunyawaj Kamolwongwat, an MP with the progressive Move Forward Party, told reporters.
Mr Tunyawaj, one of the leading voices pushing for equal marriage in parliament, posed alongside fellow MPs and aides with a rainbow banner.

The new legislation changes references to "men", "women", "husbands" and "wives" in marriage laws to gender-neutral terms.
It also gives same-sex couples the same rights as heterosexual ones when it comes to adoption and inheritance.
Prime Minister Srettha Thavisin, who has been vocal in his support for the LGBTQ community and the bill, will open his official residence to activists and supporters for celebrations after the vote.
Activists will later hold a rally, featuring a drag show, in central Bangkok, where giant shopping malls have been flying the rainbow flag in a show of support since the start of Pride Month in June.
Long struggle
More than 30 countries around the world have legalised marriage for all since the Netherlands became the first to celebrate same-sex unions in 2001.
But in Asia only Taiwan and Nepal recognise marriage equality. India came close in October, but the Supreme Court referred the decision back to parliament.

"I am so happy to see how far we have come," said Chotika Hlengpeng, a participant in the Pride march that drew thousands of enthusiasts in Bangkok early in June.
Today's vote is the culmination of years of campaigning and thwarted attempts to pass equal marriage laws.
While the move enjoys popular support, much of Buddhist-majority Thailand still retains traditional and conservative values.
LGBTQ people, while highly visible, say they still face barriers and discrimination in everyday life.
And some activists have criticised the new laws for failing to recognise transgender and non-binary people, who will still not be allowed to change their gender on official identity documents.