The company, Ragingwire Inc., argued that it rightfully fired Ross because all marijuana use is illegal under federal law, which does not recognize the medical marijuana laws in California and 11 other states.
The justices upheld that argument in a 5-2 decision.
"No state law could completely legalize marijuana for medical purposes because the drug remains illegal under federal law," Justice Kathryn Werdegar wrote for the majority.
The U.S. Supreme Court declared in 2005 that state medicinal marijuana laws don't protect users from prosecution. The Drug Enforcement Administration and other federal agencies have been actively shutting down major medical marijuana dispensaries throughout California over the last two years and charging their operators with felony distribution charges.
Ragingwire said it fired Ross because it feared it could be the target of a federal raid, among other reasons.
The Santa Clara Valley Transportation Authority and the Western Electrical Contractors Association Inc. had joined Ragingwire's case, arguing that companies could lose federal contracts and grants if they allowed employees to smoke pot.
The conservative nonprofit Pacific Legal Foundation said in a friend-of-the-court filing that employers could also be liable for damage done by high workers.
Ross had argued that medical marijuana users should receive the same workplace protection from discipline that employees with valid painkiller prescriptions do. California voters legalized medicinal marijuana in 1996.
The nonprofit marijuana advocacy group Americans for Safe Access, which represents Ross, estimates that 300,000 Americans use medical marijuana. The Oakland-based group said it has received hundreds of employee discrimination complaints in California since it began tracking the issue in 2005.
Safe Access attorney Joe Elford said the group will now focus on urging the Legislature to pass a law protecting workers who use medical marijuana.
"We remain confident that there will be a day when medical marijuana patients are not discriminated against in the workplace," he said.
Assemblyman Mark Leno, a Democrat who represents part of San Francisco, said he will introduce legislation addressing those concerns in the next few weeks.
The ruling "strikes a serious blow to patients' rights," he said.
Eleven states have adopted medical-marijuana laws similar to California's: Alaska, Colorado, Hawaii, Maine, Montana, Nevada, New Mexico, Oregon, Rhode Island, Vermont and Washington.
The American Medical Association advocates keeping marijuana classified as a tightly controlled and dangerous drug that should not be legalized until more research is done.