The 105-18 vote in the Scottish Parliament took place after more than three hours of debate.
Iceland, France, the Netherlands, Belgium, Norway, Denmark, Sweden, Portugal and Spain are among the 15 countries in which gays and lesbians can legally marry.
Same-sex couples in England and Wales will be able to tie the knot next month. The Irish government last fall announced a referendum on whether to extend marriage rights to gays and lesbians will take place in 2015.
The Luxembourg Parliament later this year is expected to consider a same-sex marriage bill. Prime Minister Xavier Bettel, who is openly gay, said after he took office last December that he would like to see his country allow nuptials for gays and lesbians this year.
Gays and lesbians have been able to enter into civil partnerships in Scotland and across the U.K. since 2005.