Canada's Supreme Court has told the government it can legalise gay marriage without violating the constitution.
The majority of Canadians are in favour of same-sex marriage
The move comes hours after New Zealand's parliament voted to recognise civil unions between gay couples.
The non-binding legal opinion followed two days of Supreme Court hearings in October in which judges heard arguments from both sides in the debate.
The province of Alberta and religious groups had argued that marriage was a union between a man and a woman.
But the court declared that Ottawa had the authority to rule on marriage.
Prime Minister Paul Martin said his Liberal government would bring in gay marriage legislation in the new year.
He said MPs would be able to vote according to conscience, but cabinet ministers had to back the bill.
"I do not believe you can have two classes of citizens," he was quoted as saying by Reuters news agency.
'Union of two'
Opposition Conservative leader Stephen Harper vowed to oppose the move, saying: "My position will be to preserve the traditional definition of marriage in the law."
The judges said that the federal government's proposed definition of marriage as "the lawful union of two persons" would not violate the constitution.
'Registered partnerships' first legalised in Denmark, 1989
Netherlands first to offer full civil marriage rights, 2001
Norway, Sweden, Iceland, Finland, Belgium and Germany also passed laws on unions
French gay couples have limited legal rights
Reform planned for Spain, Ireland, UK
Homosexuality illegal in some US states
Civil unions approved in Vermont, 2000
'Gay marriage' allowed in San Francisco, Feb-Mar 2004
However, they stopped short of saying that the Canadian constitution actually required the government to allow gay marriage across the country.
The authorities in Ottawa had hoped that the court would go further, as this would have made it easier to pass legislation.
The court also said religious officials could not be forced to officiate at homosexual marriages against their beliefs.
Gay marriage is already legal in six of the 10 Canadian provinces and one of its three northern territories, but it remains illegal in the rest of the country.