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 - the government's bill - the most progressive of the three was passed.
The two other bills, submitted by conservative lawmakers, refer to partnerships as "same-sex family relationships" or "same-sex unions" rather than "marriages".
The government's bill is also the only one to offer limited adoption rights.
Hundreds of gay rights supporters gathered outside the building in the capital of Taipei to await the landmark ruling.
Several same-sex activists had said ahead of the vote that it 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 coordinator of rights group Marriage Equality Coalition Taiwan told Reuters.
"If one of the two other bills is passed, we will launch another constitutional court challenge."
Earlier on Friday, Taiwan President Tsai Ing-wen said in a tweet that the island had a "chance to make history" with the vote.
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 - it had until 24 May to do so.
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.
As a result, Taiwan said it would not alter its existing definition of marriage in civil law, and instead would enact a special law for same-sex marriage.