Canada is the second country in the world to legalize marijuana, paving the way for recreational sales throughout the country.

Canada's Upper House of Parliament on Tuesday evening approved the revised bill 52-29, making Canada the first G7 country to legalize marijuana. Uruguay did so in 2013.

Prime Minister Justin Trudeau said on Wednesday that legalization would officially take effect on October 17, citing provincial requests for more time to develop retail infrastructure.

"It's been too easy for our kids to get marijuana — and for criminals to reap the profits," Trudeau said in a tweet on Tuesday evening. "Today, we change that. Our plan to legalize & regulate marijuana just passed the Senate."

What the bill does

Bill C-45, known as the Cannabis Act, legalizes marijuana but leaves it up to each province to decide how to sell it. Some provinces, like Ontario, are planning on provincially run outlets, while others, like Alberta, will open up marijuana retail to the private sector.

The federal government set a minimum age of 18 to purchase marijuana, though some provinces have indicated they will raise the age to 19, mirroring liquor-purchase laws. The bill makes the distribution and sale of marijuana to minors an offense.

The bill was part of a promise that Trudeau's Liberal Party made during the 2015 campaign to keep marijuana out of young people's hands and move the illicit market into a regulated framework.

"I'm feeling just great," Sen. Tony Dean, who sponsored the bill in Canada's Senate, told the Canadian Broadcasting Corporation. "We've just witnessed a historic vote for Canada. The end of 90 years of prohibition. Transformative social policy, I think. A brave move on the part of the government."

Activists applauded the move

Cannabis activists cheered the move on Wednesday morning.

"Canada should be applauded for taking bold and decisive steps towards ending the failed prohibition of marijuana," Hannah Hetzer, the senior international policy manager for the Drug Policy Alliance, said in a statement. "Canada's progress will galvanize support for drug policy reforms in the US and all around the world."

Erik Altieri, the executive director of the National Organization for the Reform of Marijuana Laws, echoed Hetzer's sentiment.

"We applaud Canada for showing federal legislators in the United States what can be accomplished with true leadership and dedication to sound public policy," Altieri said in a statement.

Golden Leaf Holdings, a cannabis company listed on the Canadian Securities Exchange, was the biggest gainer, with the stock surging 6.8%.

Legalized marijuana is expected to be a boon for Canada's economy. The Canadian Imperial Bank of Commerce, one of the country's largest banks, predicts that Canada's legal marijuana market will be a $6.5 billion industry by 2020.

Several Canadian marijuana firms, including Aurora Cannabis and Canopy Growth Corporation, are seeing a wave of investor excitement around marijuana legalization. Marijuana companies have been capitalizing on that liquidity to go on acquisition sprees.