Cannabis advocates notched a major victory when a federal appeals court banned the government from prosecuting medical marijuana users and growers in 25 states where the practice is legal, despite it still being a federal crime.

The Ninth US Circuit Court of Appeals’ three-judge panel has ruled that the Department of Justice (DOJ) cannot spend budget money to prosecute people who grow, sell or use medical marijuana, if they comply with state law.

“If the federal government prosecutes such individuals, it has prevented the state from giving practical effect to its law,” Circuit Judge Diarmuid O’Scannlain wrote for the court.

Under a 2014 congressional budget rule, the DOJ cannot use funds to prevent US states “from implementing their own state laws that authorize the use, distribution, possession, or cultivation of medical marijuana.”

Medical marijuana research farms to grow, but pot remains 'dangerous drug' https://t.co/xZmZUnI2f2pic.twitter.com/ixjs6XY8k2 — RT America (@RT_America) August 11, 2016

This recent appeals ruling affects nine western states in the Ninth Circuit’s jurisdiction, eight of which currently have some type of medical marijuana law.

However, the ruling is in particular a victory for 10 defendants, prosecuted in federal courts in San Francisco, Los Angeles and Spokane, Washington, who challenged their federal charges.

Five California men currently prosecuted are accused of operating four Southern California marijuana stores and five indoor marijuana grows in the San Francisco and Los Angeles areas, KRON news reported.

They demanded that their federal charges should be dismissed.

Now lower courts will have to determine whether or not the defendants in question had complied with state law before the charges can be dropped.

However, Judge O’Scannlain specifically stressed that the court’s unanimous ruling should not be seen as immunity by medical marijuana purveyors, Reuters said.

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

The panel has also warned that “individuals who do not strictly comply with all state-law conditions” can be prosecuted.

However, a lawyer for one of the defendants, Steve McIntosh of Los Angeles, says the Tuesday ruling could be “the beginning of the end of the federal war on medical marijuana,” according to KRON.

READ MORE: California to vote on legalization of recreational marijuana after 600k signatures gathered

Twenty-five US states currently allow for medical marijuana while another four states Colorado, Washington, Oregon and Alaska, as well as the District of Columbia allow marijuana for recreational use. This November, voters in nine more states, including California, are set to decide on whether recreational use of marijuana should be made legal there as well.