Massachusetts companies cannot fire employees who have a prescription for medical marijuana simply because they use the drug, the state’s highest court ruled Monday, rejecting employers’ arguments that they could summarily enforce strict no-drug policies against such patients.

Supreme Judicial Court Chief Justice Ralph D. Gants said a California sales and marketing firm discriminated against an employee of its Massachusetts operation who uses marijuana to treat Crohn’s disease when it fired her for flunking a drug test.

In Massachusetts, Gants wrote, “the use and possession of medically prescribed marijuana by a qualifying patient is as lawful as the use and possession of any other prescribed medication.”

Therefore, he said, employers can’t use blanket anti-marijuana policies to dismiss workers whose doctors have prescribed the drug to treat their illnesses.