Thailand's parliament has voted to approve cannabis for medical use, with a key lawmaker calling it a "New Year's gift" to the Thai people.
Recreational use will remain illegal.
Marijuana was used in Thailand as a traditional medicine, until it was banned in the 1930s.
South East Asia has some of the world's toughest penalties for drug usage or possession, and Thailand is the first in the region to allow medicinal marijuana.
Thailand's junta-appointed parliament voted to amend the Narcotic Act of 1979 on Tuesday.
It happened after an extra parliamentary session was arranged to push bills through before the New Year's holidays, according to Reuters news agency.
The amendment will become law when it is published in the government gazette, The Bangkok Post reported.
"This is a New Year's gift from the National Legislative Assembly to the government and the Thai people," said Somchai Sawangkarn, chairman of the drafting committee, during the televised session.
What will be allowed?
Consumers will be able to carry specified amounts necessary for medicinal purposes, if they have a prescription or recognised certificate, the Bangkok Post said.
Licences for production and sale of the product will be strictly controlled.
The paper said the law also applies to kratom, a South East Asian plant that acts as a stimulant.
Across the world, countries have been revisiting their marijuana laws.
Canada and Uruguay are among those to have legalised it, including for recreational use. However South East Asia is known for having very harsh punishments for drugs-related charges.
Earlier this year, a man in Malaysia was given a death sentence for selling cannabis oil.
Meanwhile, on the Indonesian island of Bali, a British man is facing up to 15 years in prisonafter being found with cannabis oil which he says he needed for medical reasons.
The 45-year-old Pip Holmes, from Cornwall, says he asked a friend to send it to him while he was living in Bali to help his arthritis.
Medical cannabis - what the research says
Conclusive or substantial evidence that it helps:
- as treatment for chronic pain in adults
- as treatment for chemotherapy-induced nausea and vomiting
- for improving patient-reported multiple sclerosis spasticity symptoms
Moderate evidence that it helps:
- improving sleep in individuals with specific conditions including fibromyalgia and obstructive sleep apnoea syndrome
- Recent studies have found that cannabidiol (CBD - an active ingredient in cannabis) reduced seizures in individuals with rare childhood epilepsy disorders - Lennox-Gastaut syndrome and Dravet syndrome