Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

OTTAWA — The Canadian government introduced legislation on Thursday that put the country on track to make recreational marijuana use legal by July 2018, with plans to regulate production but left the details of how the drug will be sold up to the provinces.

Although recreational marijuana use has been legalized in some U.S. states, including Colorado and Washington, Canada would be the first Group of Seven country to legalize it nationally. Medical marijuana is already legal in Canada.

The ruling Liberal party made legalizing recreational marijuana part of its successful 2015 election campaign. Prime Minister Justin Trudeau has argued that making marijuana legal will keep it out of the hands of underage users and reduce drug-related crime.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

This file photo taken on April 20, 2016 shows a woman waving a flag with a marijuana leaf on it next to a group gathered to celebrate National Marijuana Day on Parliament Hill in Ottawa, Canada. CHRIS ROUSSAKIS / AFP - Getty Images

"Criminal prohibition has failed to protect our kids and communities and we need a new approach," said Bill Blair, the government's point man on the issue and a former police chief.

The legislation would set the minimum legal age for use and purchase at 18, though provinces would be able to raise the age.

Provinces will be allowed to sell only cannabis grown by a licensed producer. In jurisdictions that do not put a regulated retail framework in place, Canadians would be able to purchase marijuana from regulated producers online.

Packaging would not be allowed to appeal to youth, include endorsements, or associate cannabis with a certain "way of life," according to the legislation. An official panel recommended late last year that the government require plain packaging.

Shares of licensed marijuana producers were trading lower following the announcement, including Canopy Growth Corp , which was off 2.8 percent to C$10.03, while OrganiGram Holdings Inc slipped 4.8 percent to C$2.95.

The market action was likely a "sell the news" reaction as the legislation was largely in line with what an official task force recommended last year, said Aaron Salz, founder of Stoic Advisory.

The legislation will be reviewed in Parliamentary committees, where alterations could be made. But it is ultimately all but guaranteed to pass, as the Liberals have a majority in the House of Commons.