Thailand's legislature has agreed to amend the country's drug laws to allow the licensed medical use of marijuana, as well as kratom, a locally grown plant traditionally used as a stimulant and painkiller.

Thailand on Tuesday became the first country in Southeast Asia to take such action, which is also under consideration in neighbouring Malaysia. New Zealand's government earlier this month enacted a law liberalizing the medical use of marijuana, which had previously been tightly restricted.

The Thai legislation passed its final reading at the National Legislative Assembly by a vote of 166-0 with 13 abstentions.

The changes, which become law when published in the Royal Gazette, legalize the production, import, export, possession and use of marijuana and kratom products for medical purposes.

Purveyors, producers and researchers will need licences to handle the drugs, while end-users will need prescriptions.

Recreational use of the drugs remains illegal and subject to prison terms and fines commensurate with the quantities involved. As with most countries in the region, illicit drug trafficking can be punishable by death.

Kratom, a coffee-like plant native to Southeast Asia, is sometimes taken by people to treat opioid addiction. (Earth Kratom)

Public hearings showed overwhelming support for legalizing medical cannabis and kratom, a substance produced from the leaves of a tropical tree. Kratom is sometimes taken to treat anxiety, opioid addiction, depression and other conditions, but is also used recreationally for its mild psychotropic effects.

The bill introducing the legislative changes had noted that recent studies have shown marijuana extract has medicinal benefits, which has prompted "many countries around the world to ease their laws by enacting legal amendments to allow their citizens to legally use kratom and marijuana for medicinal or recreational purposes."

It added that despite being classified as an illegal drug, many patients have used marijuana to treat their diseases.