The Labour government had promised to introduce the bill as its first law after winning a second term last month. Both opposition parties supported it, ensuring its passage.

The aim of the law, piloted by Malta equality minister Helena Dalli, was to "modernise the institution of marriage" to extend it to all consenting adult couples.

Its passage marked the latest evidence of the transformation of the once-conservative nation of about 440,000 people, where divorce was illegal until 2011.

While abortion remains banned in Malta, adoption by same-sex couples has been legal since civil unions were introduced in 2014. Last year, the number of exclusively civil marriages eclipsed the number of church weddings for the first time.

Archbishop Charles Scicluna had opposed the same-sex marriage law, reflecting the church's long-standing view that marriage can only be between a man and woman.

"I can decide that a carob and an orange should no longer be called by their name," he said in a homily a few days after parliament started debating the legislation.

"But a carob remains a carob and an orange remains an orange. And marriage, whatever the law says, remains an eternal union exclusive to a man and a woman."

Prime Minister Joseph Muscat had said it would be "discriminatory" to have separate laws for mixed and same-sex couples. So the amendments to existing laws included eliminating any reference to "husband and wife". In its place is now the gender-neutral term "spouse" to cover all situations.

The law also calls for the removal of the terms "father" and "mother", to be substituted by "parents". Lesbian couples who have children via medical interventions are distinguished by the terms "the person who gave birth" and "the other parent".

Other changes concern heterosexual marriages: Any reference to "maiden name" is replaced with "surname at birth", while couples can now choose what surname to take after marriage. A man, for example, can take his wife's surname.

More than a dozen European countries have legalised same-sex marriage, all in the western part of the continent.

Almost a dozen others, including Italy, have some sort of same-sex unions or civil partnerships, according to the Pew Research Centre.