In 2017, the island's constitutional court ruled that same-sex couples had the right to legally marry.
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.