Even with dozens of states such as California now allowing the sale of medical marijuana and a handful of others legalizing weed altogether, Oakland’s Harborside Health Center, the nation’s largest medicinal cannabis dispensary, is still locked in a legal fight for survival with the federal government.

On Tuesday, Harborside’s two-year standoff with the U.S. Justice Department reaches a federal appeals court, which is set to consider Oakland’s novel legal move to block the government’s seizure of the dispensary through forfeiture laws.

The 9th U.S. Circuit Court of Appeals is reviewing a 2013 lower court ruling tossing out Oakland’s lawsuit, which argues that a federal government shutdown of one of four city-approved and regulated medical marijuana outfits harms the city’s interests.

Despite that ruling, U.S. Magistrate Judge Maria Elena James has put the government’s forfeiture case against Harborside on hold while the appeals court reviews the issues — a move that has allowed the dispensary to continue to sell medical pot to patients in Oakland, as well as its smaller facility in San Jose.

Legal experts say Oakland may have a tough sell with the appeals court, given the government’s sweeping powers under federal drug laws. The government moved to shutter the East Oakland dispensary, labeled a medical pot “superstore,” because it is so large that it was alleged likely to sell to customers who could not prove a medical need.

“The city of Oakland has a really difficult, uphill battle here,” said former federal prosecutor Rory Little, a Hastings College of the Law professor.

Nevertheless, while the case may mark a crucial stage in Harborside’s attempt to stave off closing an operation that generates more than $20 million a year in business, it may not be the final word. Even if the 9th Circuit sides with the government, Harborside may lose a battle but win the war.

In a recent development, Congress included a provision in December spending legislation — signed by President Barack Obama — that appears to bar the federal government from using resources to prosecute medical marijuana providers in the 32 states where it is legal.

U.S. Attorney Melinda Haag, who filed the forfeiture action against Harborside, declined to comment on the case. And U.S. Justice Department officials, who are defending the government against Oakland’s lawsuit in the 9th Circuit, have not addressed how the legislation affects situations such as Harborside.

But Harborside’s supporters are using the legislation to back Oakland’s arguments, telling the 9th Circuit in court papers that the congressional action “reaffirms the government’s policy of non-prosecution of persons acting in compliance with state and municipal laws regarding medical marijuana.”

Steve DeAngelo, Harborside’s co-founder, could not be reached for comment, but he has vowed repeatedly to fight to keep his doors open to medical marijuana patients. He has Oakland’s strong support, as city officials maintain keeping it operating is important for everything from tax revenue to alleviating black market pot sales on city streets.

“The government’s position on medical marijuana is schizophrenic,” said Cedric Chao, the lawyer representing Oakland. “The whole case makes the government uncomfortable.”

The Obama administration, at the direction of Attorney General Eric Holder, in recent years shifted course on medical marijuana enforcement, for the most part abandoning prosecution in states where medical weed is legal. California voters approved medical pot in 1996.

But there have been some crackdowns, primarily aimed at dispensaries proliferating without much oversight in areas such as near schools and parks. The Harborside action, filed two years ago, came before some of the more recent shifts in Justice Department enforcement.

Government lawyers, however, still argue that Oakland has no legal basis to block the Harborside forfeiture and interfere with enforcement of federal drug laws. “The city cannot plausibly claim to be in the zone of interests protected by the federal law at issue here,” Justice Department lawyers told the 9th Circuit.

Oakland concedes the city’s argument is unique — but insists that Harborside’s situation is likewise unique.

“Oakland is clearly harmed,” Chao said.

Howard Mintz covers legal affairs. Contact him at 408-286-0236 or follow him at Twitter.com/hmintz