Sweden will allow gay couples to be legally married from next month.
Parliament voted overwhelmingly on Wednesday to recognise same-sex marriage, becoming the fifth country in Europe to do so.
Sweden was one of the first countries to give gay couples legal "partnership" rights, in the mid-1990s, and allowed them to adopt children from 2002.
The new law lets homosexuals wed in either a civil or religious ceremony, though individual churches can opt out.
The law was passed by 226 votes to 22 and will come into force on 1 May.
"The decision means that gender no longer has an impact on the ability to marry and that the law on registered partnership is repealed," the government said on its website.
Six of the seven parties in parliament backed the bill, while the Christian Democrats, one of four parties in the governing coalition, refused.
The Lutheran Church, the largest church in Sweden, has offered to bless gay partnerships since January 2007, but has still not given formal backing to the term "marriage", and will allow individual pastors to refuse to carry out gay weddings.
Sweden has become the fifth European country, after the Netherlands, Belgium, Spain and Norway, to recognise same-sex marriage.
Elsewhere, Canada and South Africa have also passed such legislation, as have some US states and local authorities in other countries.