The Canadian Senate has approved a bill legalising same-sex marriages, following a similar decision by the lower house of parliament last month.
Eight Canadian provinces already allowed same-sex marriages
It makes Canada the fourth country in the world to give gay couples the same rights as male-female partners, after Belgium, the Netherlands and Spain.
Same-sex marriage was already legal in most Canadian provinces, but the new legislation applies nationwide.
The bill was passed after years of divisive debate.
The law, drafted by the Liberal Party of Prime Minister Paul Martin, was opposed by the opposition Conservative Party and some religious leaders.
It was approved by 47 votes to 21, and could be signed into law as early as Wednesday.
Gay marriage was already legal in eight of 10 provinces and one of Canada's three territories.
The legislation puts Canada on a quite different course to its powerful neighbour to the south.
In the US, President George W Bush is seeking a constitutional amendment that would define marriage as being between a man and a woman.
Hundreds of foreigners, including Americans and Israelis, have gone to Canada for civil unions since gay marriage was first allowed in some provinces in 2003.