Canada's top court says Ottawa has the authority to redefine marriage to include same-sex couples, but religious officials cannot be forced to perform unions against their beliefs.
The Supreme Court of Canada refused to say whether the traditional definition of marriage - between one man and one woman - violates equality rights.
It noted the federal government has already accepted lower-court judgments that excluding gays from marrying is discriminatory.
"The government has clearly accepted the ruling of lower courts on this question and has adopted their position as its own.
"The parties to previous litigation have now relied upon the finality of the judgments they obtained through the court process."
The court says times have changed and the legal definition of marriage should change with them.
"Several centuries ago, it would have been understood that marriage be available only to opposite-sex couples.
"The recognition of same-sex marriage in several Canadian jurisdictions as well as two European countries belies the assertion that the same is true today."
Still, the Charter of Rights and Freedoms clearly protects religious freedom, says the court.
The court's landmark advisory opinion signals the final stage of a long, bitter fight over whether gays and lesbians should be allowed to marry.
Justice Minister Irwin Cotler predicted Wednesday that the court would give the Liberals a green light to move ahead with a bill to legalize same-sex unions as early as this month.
Same-sex marriage could become legal across the country next year if the minority Liberals win enough support in the divided House of Commons.
It's expected a vote on legalizing gay weddings would narrowly pass even without the support of several Liberals and the Conservatives.
Judges in six provinces and one territory have already struck down the traditional marriage definition, saying it violates equality rights. Thousands of same-sex couples have already tied the knot.
Should the legislation pass, Canada would join Belgium and the Netherlands in allowing gays to wed.
The high court opinion on same-sex unions is strictly advisory.
Still, its political aftershocks will reverberate among pro-and anti-gay marriage factions across Canada.
The high court reference comes 18 months after former prime minister Jean Chretien abandoned his government's fight against same-sex marriage by refusing to appeal provincial court rulings in Ontario, British Columbia and Quebec that declared traditional marriage laws unconstitutional.
His government then drafted legislation that would allow gay and lesbian weddings in city halls, courthouses and in religious institutions that choose to perform them.
To ensure the bill is legally bullet-proof, the Liberal government asked the high court three questions:
-Does the federal government have exclusive authority to define marriage? The question was a pre-emptive strike at any provincial attempt to thwart the new law. Alberta Premier Ralph Klein has said he would use the Constitution's notwithstanding clause to cancel the legislation in his province.
-Does the charter protect religious groups from having to perform gay weddings against their beliefs?
-Is the proposed same-sex marriage law constitutional?
Prime Minister Paul Martin expanded the reference after he was sworn in last December, adding a fourth question: Is the traditional definition of marriage - between one man and one woman - also constitutional? This was aimed at clarifying once and for all whether the century-old definition of marriage is flawed.
The federal Conservatives and several Liberal MPs are expected to wage a bitter final battle to preserve marriage for heterosexuals.