The Cannabis Act passed its final hurdle on Tuesday in a 52-29 vote in the Senate. The bill controls and regulates how the drug can be grown, distributed, and sold.
Canadians will be able to buy and consume cannabis legally as early as this September.
The country is the second worldwide to legalise the drug's recreational use.
Uruguay became the first country to legalise the sale of cannabis for recreational use in December 2013, while a number of US states have also voted to permit it.
Cannabis possession first became a crime in Canada in 1923 but medical use has been legal since 2001.
The bill will likely receive Royal Assent this week, and the government will then choose an official date when the law will come into force.
Prime Minister Justin Trudeau tweeted that until now, "it's been too easy for our kids to get marijuana - and for criminals to reap the profits".
But some groups objected to the new law, with opposition Conservative politicians and indigenous groups among those voicing concerns.
The government is expected to give the provinces and territories, as well as municipalities, eight to 12 weeks to set up the new marijuana marketplace.
This timeframe will also allows industry and police forces to prepare for the new legal framework.
In 2015, Canadians were estimated to have spent about C$6bn ($4.5bn, £3.4bn) on cannabis - almost as much as they did on wine.
More about: Canada