Canadian Prime Minister Justin Trudeau speaks to the press following a robotics demonstration at Kinova Robotics in Boisbriand, Quebec, Canada March 24, 2017. Reuters/Christinne Muschi Canada's Liberal government on Thursday introduced long-awaited legislation to legalize marijuana by July 2018, taking Prime Minister Justin Trudeau one step closer to fulfilling a key campaign promise.

The two bills, if passed, will allow people to possess up to 30 grams of dried or fresh cannabis. Consumers will be permitted to grow up to four plants themselves, or they will be able to purchase marijuana from licensed retailers.

The legislation also includes harsh penalties of up to 14 years in jail for illegally selling or distributing marijuana, or giving it to minors. Offenders can also receive up to 14 years in jail for using a youth to commit a cannabis-related offense.

Under the bill, possession of amounts larger than 30 grams would be subject to penalties such as tickets or up to five years in jail, depending on the amount.

At a press conference Thursday announcing the bills, four federal ministers emphasized that the legislations' goals are twofold: to cut off profits from marijuana sales from organized crime, and to restrict marijuana access to minors by creating new criminal offenses that carry heavy penalties.

"If your objective is to protect public health and safety and keep cannabis out of the hands of minors and stop the flow of profits to organized crime, then the law as it stands today has been an abject failure," public safety minister Ralph Goodale said, noting that police forces spend up to $3 billion each year dealing with cannabis and yet Canadian teenagers remain among the heaviest users in the western world.

"We simply have to do better," he said.

A Canadian flag with a marijuana leaf is flown during a 4/20 rally to demand the legalization of marijuana on Parliament Hill in Ottawa April 20, 2012. Reuters/Patrick Doyle

The bills stipulate that consumers be a minimum age of 18 to purchase marijuana, but provinces will be permitted to raise that age if desired.

Another key component of the legislation is cracking down on impaired driving. The bills create new criminal offenses for those who drive under the influence of cannabis, and authorize police to use oral fluid drug screeners during road stops if they have reasonable suspicion that the driver is impaired.

"I would like to reiterate that driving while impaired by drugs is and will remain illegal," justice minister Jody Wilson-Raybould told media.

The bills also contain strict regulations around advertising, marketing, and branding legal marijuana, so as not to appeal to youth.

The legislation was shaped by recommendations laid out by a federal task force, which has attracted significant public support. The legislation is expected to be passed through Parliament as parties both to the right and left of Trudeau's Liberal government have signaled support.

Provinces and territories are expected to heavily scrutinize the legislation over the coming months to sort out details around distribution and law enforcement, the Canadian Press reported.

If passed, Canada's legislation will make the country the first of the G7 members to legalize nationwide recreational use. Uruguay is currently the only other country in the world to fully legalize recreational use.

The legislation could potentially yield international ramifications. Canada is a signatory to three international treaties that require countries to criminalize recreational marijuana, and will likely need to amend its involvement.

The ability of Canadian travelers to cross the US border could also come into question — American border guards may deny entry to Canadians who admit they have smoked marijuana in the past. The government has previously said it hoped to broach the topic with the US government.

But in response to media questions about how Canadians who have smoked marijuana should answer American border guards, Goodale would only say that they should not lie.

"Every sovereign country has the ability to make those decisions for themselves," he said.

Jeremy Berke contributed to this report.