Uruguay's lower house of Congress voted on Wednesday to create a government body to control the cultivation and sale of marijuana and allow residents to grow it at home or as part of smoking clubs.
The use of marijuana is already legal in the South American nation, but sale and cultivation is not.
After hours of spirited debate, 50 lawmakers voted for the bill and 46 against it. The Senate is expected to vote on the measure backed by leftist President Jose Mujica later this year.
Mujica, a former leftist guerrilla fighter, says the bill would control the marijuana trade under strict guidelines, help undermine drug-smuggling gangs and fight petty crime.
To avoid making the country a drug tourism destination, only Uruguayans would be allowed to use marijuana.
Critics say the measure risks luring more Uruguayans to harder drugs and could rile fellow Latin American countries battling drug-related violence such as Colombia and Mexico.
Uruguay is one of Latin America's safest countries and is considered a trailblazer on liberal lawmaking. But polls show most Uruguayans oppose the proposal.
"We are playing with fire," said congressman Gerardo Amarilla, a member of the conservative National Party, which opposes the bill.
"In trying to find an outlet for change we are burying ourselves in a reality that is far worse," Amarilla added.
The legislation would establish a National Cannabis Institute to control the drug's production and distribution, impose sanctions on rule-breakers and design educational policies to warn about the risks of marijuana use.
Households would be permitted to grow up to six plants, or as much as 480 grams (about 17 ounces) of marijuana per year under the measure. It also would set regulations for smoking clubs with up to 15 members, 90 plants and annual production of up to 7.2 kilograms (15.8 pounds).
"You can control production and sale, which will bring its own problems that will have to be addressed," said lawmaker Julio Bango, a Mujica ally in favor of the legislation. "Or you can have what you have now, which is chaos."