Sweden has adopted a law that legalizes same-sex marriage, making it the seventh country in the world to allow gay and lesbian couples to wed in either a religious or civil ceremony.

After hours of debate, the Swedish parliament voted 261 to 22, with 66 abstaining or absent, on Wednesday to approve a gender-neutral law on marriage.

Christian Democrats opposed the legislation.

The new legislation repeals a 1987 law that defines marriage as between a man and a woman. Sweden now joins the Netherlands, Belgium, Spain, Canada, South Africa and Norway in allowing same-sex marriage. In the United States, homosexual marriage is legal in Massachusetts and Connecticut.

The new law takes effect May 1 and allows individual pastors the freedom to opt out of marrying same-sex couples.

The Lutheran Church of Sweden has already expressed support for the new law, according to Agence France-Presse.