Peru has approved measures to legalise cannabis for medicinal use with overwhelming support of congress.
The law makes production, import and commercial sale of cannabis oil legal.
President Pedro Pablo Kuczynski had proposed the measure earlier this year, raising objections that drug gangs would branch into cannabis.
Peru is the second-largest producer of coca and has a thriving illegal drug trade. It is now the sixth country in Latin America to legalise cannabis.
Uruguay was first in 2013, allowing sales with a limit of 40 grams per month. Mexico, Argentina, Colombia and Chile followed suit.
President Kuczynski proposed the relaxation in February after police arrested a group of parents who were distilling cannabis oil at home, for children with cancer and severe epilepsy. The drug will only be sold to those who are fully registered with a licensed pharmacy.