DENVER — Even in one of the country’s most marijuana-friendly states, smoking pot off the job and away from work can still get an employee fired.

That was the unanimous conclusion of the Colorado Supreme Court on Monday, in a closely watched workplace lawsuit involving a customer service worker who uses medical marijuana to help soothe the painful spasms he has suffered since a car accident left him paralyzed. The worker, Brandon Coats, was fired from Dish Network in 2010 after testing positive for marijuana in a random drug test.

The court’s decision was a blow to marijuana advocates, who have consistently seen court rulings go against them, with judges in Colorado and elsewhere saying that companies have the right to create their own drug policies. The loss by Mr. Coats highlights the limits of marijuana legalization at a time when more states are approving medical or recreational uses of a drug that is still outlawed as a Schedule I controlled substance by the federal government.

“The federal government has in many ways the last say,” said Sam Kamin, a law professor at the University of Denver who studies legal issues swirling around marijuana’s growing place in society. “As long as that federal prohibition is in place, the states can only do so much.”