MONTEVIDEO, Uruguay — Uruguay has become the first country to create a national marketplace for legal marijuana, with the government regulating the production, sales and use of pot in a bold bid to control addiction and drug violence.

The Senate gave final legislative approval to the bill late Tuesday, and President Jose Mujica, who campaigned for the legislation, is expected to sign it into law. The 78-year-old president has said he wants the market to begin operating next year.

“Today is an historic day. Many countries of Latin America, and many governments, will take this law as an example,” Sen. Constanza Moreira, a member of the governing Broad Front coalition, said as the bill passed with 16 votes in favor and 13 against. Congress’ lower house approved the measure in late July.

But Mujica, a former leftist guerrilla who spent years in jail as a younger man while others experimented with marijuana, went ahead with the legislation anyway. He argued the global drug war is a failure and said bureaucrats can do a better job of containing addictions and beating organized crime than police, soldiers and prison guards.

Uruguay’s drug control agency will have 120 days, until mid-April, to draft regulations imposing state control over the entire market for marijuana, from seed to smoke.

Everyone involved must be licensed and registered, with government monitors enforcing limits such as the 40 grams a month any adult will be able to buy at pharmacies for any reason or the six marijuana plants that license-holders will be allowed to grow at home.

“This is not liberalization of marijuana. It can be consumed within certain parameters established by law. I think it will reduce consumption,” Sen. Luis Gallo, a retired doctor who favored the bill, told The Associated Press.

Opponents warned of the possible effects on health.

Former Health Minister Alfredo Solari, a Colorado Party senator, worried the law will make it easier for children and adolescents to get their hands on pot. “The effects of this policy on public health will be terrible,” he said.

The government got help from a national TV campaign and other lobbying efforts supporting by billionaire currency speculator and philanthropist George Soros and his Open Society Foundation and Drug Policy Alliance. In September, Mujica met with Soros and billionaire David Rockefeller in New York to explain his legal-market plan.

These deep-pocketed connections drew criticism from the president’s opponents.

“I would say to Mr. Soros, to Mr. Rockefeller, and to the president of the republic that you don’t experiment with the Uruguayans. We are not guinea pigs,” Colorado Party Sen. Pedro Bordaberry said Tuesday.

Hannah Hetzer, a lobbyist for the Alliance who moved to Montevideo for the campaign, watched closely from the Senate gallery.

“Uruguay is seeking an alternative to a failed model. I think that this is the beginning of the end of a prohibitionist model and the beginning of a more intelligent focus,” she said.