TEL AVIV (JTA) — An Israeli Orthodox rabbi ruled that distributing and smoking medicinal marijuana is kosher, but using weed for fun is forbidden.

Efraim Zalmanovich, the rabbi of Mazkeret Batia, a town south of Tel Aviv, made the distinction in a recent halachic ruling, NRG, the news site of the Maariv daily reported on Friday. Leading rabbis frequently weigh in on matters of reconciling halachah, or Jewish law, with modern living.

Zalmanovich’s ruling modifies an opinion by Rabbi Hagai Bar Giora,who in March told Israel’s Magazin Canabis: “If you smoke it, there is no problem whatsoever.”

Zalmanovich, the author of a book on alcoholism in Judaism, said: “Taking drugs to escape this world in any excessive way is certainly forbidden.”

However, if the drug is administered to relieve pain, then the person giving it is “performing a mitzvah,” and the person using the drug is using it “in a kosher fashion.”

Some 11,000 Israelis use medicinal marijuana, including people with post-traumatic disorders and Parkinson’s disease, according to the Israeli health ministry.