Though medical marijuana is now legal in 25 states and Washington, DC, the drug still remains strictly banned under federal law, a contradiction that has long made even the most compliant patients, growers, and dispensary owners nervous about getting busted by the feds. But at least some of them can relax — for now.

That's because a federal court in San Francisco ruled this week that the Department of Justice can't spend money to prosecute people who obey their state's medical marijuana laws.

The decision, handed down on Tuesday by the Ninth Circuit Court of Appeals, solidifies the legal standing of a rule that was attached to a 1,603-page federal spending bill passed by Congress in 2014 and later extended through September 2016. As noted by the court, the budget caveat — commonly known as a rider — expressly forbids federal authorities from spending taxpayer money on prosecuting medical marijuana cases against individuals who have "fully complied" with state laws.

The case, USA v. McIntosh, grouped together appeals by 10 people from California and Washington who were prosecuted for violating the Controlled Substances Act, the federal statute that outlaws weed. The case's eponymous defendant, Steve McIntosh, faced conspiracy charges related to more than 1,000 pot plants linked to five Los Angeles–area marijuana stores and nine grow operations. The other cases involved similarly massive hauls, including one in Fresno, California, where investigators found more than 30,000 plants.

"If DOJ [the Department of Justice] wishes to continue these prosecutions, the appellants are entitled to evidentiary hearings to determine whether their conduct was completely authorized by state law," Judge Diarmuid O'Scannlain wrote, sending the cases back to lower federal courts for further review.

Charles Sanford Smith, a New York attorney who handles medical marijuana cases, said the ruling could effectively halt federal prosecutions while the DOJ figures out whether it's even allowed to spend money trying to prove that pot defendants have run afoul of state laws.

'You'd think they wouldn't want to spend the time or the resources on these prosecutions.'

"In some ways they've already spent money to go forward on that small process, and you can make the argument they would be spending money in violation of the appropriations rider just by prosecuting up to that point, just by filing the charges," Smith said. "It makes it more difficult for [the DOJ], and practically you'd think they wouldn't want to spend the time or the resources on these prosecutions."

Asked about that argument and the impact of the Ninth Circuit's decision, DOJ spokesperson Peter Carr replied, "We are reviewing the ruling and are declining to comment further at this time."

While the ruling offers some reassurance to law-abiding medical marijuana users in the nine Western states covered by the Ninth Circuit, Smith noted that judges elsewhere might not have the same interpretation of the law and could still allow federal prosecutions. (In addition to the 25 states that allow medical patients to smoke cannabis, 40 states have laws allowing the use of cannabinol and other products derived from weed.)

And, as O'Scannlain pointed out on Tuesday, the budget rider is a stopgap protection that could soon be eliminated.

"Congress could restore funding tomorrow, a year from now, or four years from now," the judge wrote, "and the government could then prosecute individuals who committed offenses while the government lacked funding."