A U.S. federal judge ruled on Monday that the Department of Justice is breaking the law when it interferes with or shuts down medical marijuana dispensaries that are in compliance with state law.

Senior District Judge Charles R. Breyer lifted an injunction against California's oldest medical marijuana dispensary, Marin Alliance for Medical Marijuana (MAMM), and its owner Lynette Shaw. Breyer said the injunction can no longer be enforced due to a spending amendment approved by Congress in December 2014 that requires the federal government to respect state medical marijuana laws, reported The Washington Post.

It was the first known ruling by a federal judge to protect cannabis dispensaries under the budget amendment and sets significant legal precedent, reported The San Francisco Chronicle.

"[T]he plain reading of [Congressional law] forbids the Department of Justice from enforcing this injunction against MAMM to the extent that MAMM operates in compliance with state California law," Breyer wrote in his ruling, adding: "The mayor of the Town of Fairfax [stated] MAMM was operating as a model business in careful compliance with its local use permit in a 'cooperative and collaborative relationship' with the community."

The bipartisan Rohrabacher-Farr Amendment was added to a federal spending bill signed by President Barack Obama in December 2014 and prohibits the DOJ from using federal funds to prosecute medical marijuana dispensaries operating in compliance with state law, according to The Huffington Post.

The DOJ interpreted the amendment narrowly by claiming the congressional restriction did not apply to individual cases and continued to target people who were complying with their state medical marijuana laws, according to the Los Angeles Times. That interpretation was made even though Obama promised on the campaign trail in 2007 to stop the DOJ from prosecuting and raiding medical marijuana users.

Breyer said the Drug Enforcement Administration's interpretation of the bill "defies language and logic," "tortures the plain meaning of the statute" and is "at odds with fundamental notions of the rule of law."

The ruling allows Shaw, who ran her marijuana dispensary from 1997 until a federal forfeiture action closed it in 2012, to reopen her marijuana dispensary.

The ruling should also bring a sigh of relief to medical marijuana businesses and their patients in the 23 states and District of Columbia, which have laws that legalize and regulate medical marijuana. Twelve states have laws regulating cannabidiol oils, a non-psychoactive component of marijuana which some use to treat seizures in their children, and four states and the District of Columbia have legalized marijuana for recreational purposes.

"It's great to see the judicial branch finally starting to hold the Justice Department accountable for its willful violation of Congress's intent to end federal interference with state medical marijuana laws," said Tom Angell of Marijuana Majority, according to The Washington Post.

Dan Riffle of the Marijuana Policy Project agreed, saying, "This is a big win for medical marijuana patients and their providers and a significant victory in our efforts to end the federal government's war on marijuana. Federal raids of legitimate medical marijuana businesses aren't just stupid and wasteful, but also illegal."