An appeals court ruled Tuesday that a federal law outlawing marijuana does not apply to sick people who are allowed to smoke pot with a doctor's recommendation.

The ruling by the 9th U.S. Circuit Court of Appeals (search) was a blow to the federal government in its fight against medical marijuana. The Justice Department has argued that state medical marijuana laws were trumped by federal drug laws.

The case also underscores the conflict between federal law and California's 1996 medical marijuana law, which allows people to grow, smoke or obtain marijuana for medical needs with a doctor's recommendation. Eight other states have similar laws.

The Justice Department (search) was not immediately available to comment on the ruling from an appeals court some call the nation's most liberal.

In its 2-1 decision, the court said prosecuting medical marijuana users under the federal law is unconstitutional if the marijuana is not sold, transported across state lines or used for non-medicinal purposes.

Judge Harry Pregerson wrote for the majority that smoking pot on the advice of a doctor is "different in kind from drug trafficking." The court added that "this limited use is clearly distinct from the broader illicit drug market."

The case concerned two seriously ill California women who sued Attorney General John Ashcroft (search). They asked for a court order letting them smoke, grow or obtain marijuana without fear of federal prosecution.

A federal judge tossed the case in March, saying the federal law barred him from blocking any potential enforcement action against medical marijuana patients Angel Raich and Diane Monson.

Tuesday's ruling sends the case back to the district judge, and while the women's case has yet to be tried, the appeals court said the two "have demonstrated a strong likelihood of success on the merits."

Raich, a 38-year-old Oakland woman suffering from ailments including scoliosis, a brain tumor, chronic nausea, fatigue and pain, smokes marijuana every few hours. She said she was partly paralyzed until she started smoking pot.

She and her doctor say marijuana is the only drug that helps her pain and keeps her eating to stay alive.

"I feel safe for the very first time ever since I've been a patient," Raich said of the ruling. "This is very triumphant not only for myself but for patients and caregivers across the country."

In dissent, Judge C. Arlen Beam said that Congress could regulate medical marijuana, noting that the Supreme Court has declared that grain is subject to federal regulation even if the grower never sold it and used it solely for his family.

Tuesday's case in an outgrowth of a 2001 decision by the Supreme Court, which ruled that medical marijuana clubs could not dole out pot on the grounds of "medical necessity," even if patients have a doctor's recommendation to use the drug.

Alaska, Arizona, Colorado, Hawaii, Maine, Nevada, Oregon and Washington state have laws similar to California, which has been the focus of federal drug interdiction efforts. Agents have raided and shut down several medical marijuana growing clubs.

The appeals court, the nation's largest, has jurisdiction over all the states except Colorado and Maine.