OTTAWA (Reuters) - Canada was on track to legalize recreational marijuana by July 2018 after the government put forward legislation on Thursday that will see it regulate production but left the details of how the drug will be sold up to the provinces.

Recreational marijuana has been legalized in some U.S. states, including Colorado and Washington, but Canada would be the first Group of Seven country to do so nationally.

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

"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 government said it will provide details on a new licensing fee and tax system in the coming months. Blair said Ottawa was talking to provinces and producers to make sure the sale price will be "appropriate."

The provinces will be responsible for overseeing and approving retail sales of cannabis. Authorities have been battling a rise in illegal dispensaries, particularly in British Columbia and Ontario, for over a year.

In jurisdictions that do not put a regulated retail framework in place, Canadians would be able to purchase marijuana online. The minimum legal age would be 18, though provinces would be able to raise that.

Only cannabis grown by a federally licensed producer will be available for sale, though Canadians could grow up to four plants at home.

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.

While medical marijuana is already legal in Canada, consulting firm Deloitte has estimated annual sales of recreational marijuana could be as high as C$8.7 billion (5 billion pounds).

Shares of marijuana producers were trading lower following the announcement, though the stocks have seen a run-up in anticipation of legalization.

Canopy Growth Corp fell 3.8 percent to C$9.92, though the stock has more than tripled in the last year. OrganiGram Holdings Inc, which has nearly doubled, fell 9.7 percent to C$2.80.

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.

(Reporting by Leah Schnurr and David Ljunggren; Editing by Dan Grebler and Lisa Shumaker)