Recreational use will remain illegal.
Marijuana was used in Thailand as 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.
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.
Consumers will be able to carry specified amounts necessary for medicinal purposes if they have a prescription or recognized certificate, the Bangkok Post said.
Licenses 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.