The bill, the culmination of more than two decades of effort by activists, was supported by an overwhelming majority of lawmakers in the upper house.
The law, which needs royal approval, will come into force 120 days after it is published in the royal gazette, meaning the first same sex weddings could take place later this year.
"Today we celebrate another significant milestone in the journey of our Equal Marriage Bill," Thai Prime Minister Srettha Thavisin said in a post on X.
"We will continue our fight for social rights for all people regardless of their status."
LGBT advocates called the move a "monumental step forward," as Thailand would be the first nation in Southeast Asia to enact marriage equality legislation and the third in Asia, after Nepal and Taiwan.
"We are very proud to make history," said Plaifah Kyoka Shodladd, member of a parliamentary committee on same-sex marriage.
"Today love triumphed prejudice ... after fighting for more than 20 years, today we can say that this country has marriage equality."
Lawmakers and activists were seen celebrating in Thailand's parliament, waving rainbow flags and smiling, with some raising their fists in solidarity with the LGBT community.
In Thailand's northern Chiang Mai province, human rights activist Matcha Phornin, her wife Veerawan Wanna and their adopted daughter were glued to their television screen as they watched the senate proceedings.
"We have support from the parliament, from the senators who passed this law. That means we are protected by law," said Matcha, after they cheered and hugged each other when the bill passed.
"And she will be legally adopted after this," Matcha said, referring to their daughter.
Thailand, one of Asia's most popular tourist destinations, is already known for its vibrant LGBT culture and tolerance.
At the start of June, thousands of revellers and activists paraded through the streets of Bangkok and were joined by Prime Minister Srettha, who wore a rainbow shirt to celebrate Pride Month.
"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 LGBTQI couples said in a statement.
(Reporting by Chayut Setboonsarng, Panarat Thepgumpanat, Chalinee Thirasupa, Artorn Pooksasook, Thomas Suen and Zaw Naing Oo; Editing by John Mair, Bernadette Baum and Christina Fincher)
Thai couple Juntagon Seneewong Na Ayutthaya (L) and her partner Kamontip Aurareemaitrichit (R) march during LGBTQ+ parade to mark the Pride Month celebrations in Bangkok, Thailand, 01 June 2024. Thousands of Thai and international LGBTQIA+ participants take part in the annual Bangkok Pride parade to mark Pride Month under the 'Celebration of Love' concept to promote diversity and equal rights for all members of society as well as to celebrate the legalization of the Marriage Equality Act after Thai lawmakers passed the bill to legalize same-sex marriage, which makes Thailand to be the first Southeast Asia country to legalize same-sex marriage. The pride month is celebrated across the world annually in June to commemorate the 1969 Stonewall uprising to raise awareness and promote sexual diversity and equal rights for the Lesbian, Gay, Bisexual, Transgender, and Queer (LGBTQ) community. EPA-EFE/RUNGROJ YONGRIT