Uruguay has become the first nation to legalise the growing, sale and smoking of marijuana after the country's Senate gave final approval to the legislation.
After a long debate on Tuesday, 16 of 29 senators voted in favour of the law championed by President Jose Mujica.
The legislation is aimed at wresting the business from criminals in the small South American nation.
Backers of the law, some smoking joints, gathered near Congress holding green balloons, Jamaican flags in homage to singer-songwriter Bob Marley and a sign saying: "Cultivating freedom, Uruguay grows."
Cannabis consumers will be able to buy a maximum of 40 grams each month from licensed pharmacies as long as they are Uruguayan residents over the age of 18 and registered on a government database that will monitor their monthly purchases.
When the law is implemented in mid-April, Uruguayans will be able to grow six marijuana plants in their homes a year, or as much as 480 grams, and form smoking clubs of 15 to 45 members that can grow up to 99 plants per year.
Registered drug users should be able to start buying marijuana over the counter from licensed pharmacies in April.
Uruguay's leftist president defends his initiative as a bid to regulate and tax a market that already exists but is run by criminals.
We've given this market as a gift to the drug traffickers and that is more destructive socially than the drug itself, because it rots the whole of society.
"We've given this market as a gift to the drug traffickers and that is more destructive socially than the drug itself, because it rots the whole of society," the 78-year-old former guerrilla fighter told Argentine news agency Telam.
Uruguay's attempt to quell drug trafficking is being followed closely in Latin America where the legalisation of some narcotics is being increasingly seen by regional leaders as a possible way to end the violence spawned by the cocaine trade.
The bill gives authorities 120 days to set up a drug control board that will regulate cultivation standards, fix the price and monitor consumption.
The use of marijuana is legal in Uruguay, a country of 3.3 million that is one of the most liberal in Latin America, but cultivation and sale of the drug are not.
Former Health Minister Alfredo Solari, a Colorado Party senator, warned on Tuesday that children and adolescents will more easily get their hands on pot and that "the effects of this policy on public health will be terrible".
But Senator Roberto Conde, a former deputy foreign minister with the governing Broad Front, said marijuana "is already established in Uruguay. It's a drug that is already seen as very low risk and enormously easy to get."
Other countries have decriminalised marijuana possession and the Netherlands allows its sale in coffee shops, but Uruguay will be the first nation to legalise the whole chain from growing the plant to buying and selling its leaves.
Several countries such as Canada, the Netherlands and Israel have legal programmes for growing medical cannabis but do not allow cultivation of marijuana for recreational use.
Last year, the US states of Colorado and Washington passed ballot initiatives that legalise and regulate the recreational use of marijuana.