SAN FRANCISCO — A federal ban on the sale of guns to medical marijuana card holders does not violate the Second Amendment, a federal appeals court said Wednesday.

The ruling by the 9th U.S. Circuit Court of Appeals applies to the nine Western states that fall under the court’s jurisdiction, including California, Washington and Oregon.

It came in a lawsuit filed by S. Rowan Wilson, a Nevada woman who said she tried to buy a firearm for self-defense in 2011 after obtaining a medical marijuana card. The gun store refused, citing the federal rule banning the sale of firearms to illegal drug users.

Marijuana remains illegal under federal law.

Wilson said she was not a marijuana user, but obtained the card in part as an expression of support for marijuana legalization.

She challenged guidance issued by the federal Bureau of Alcohol, Tobacco, Firearms and Explosives in 2011 that said gun sellers should assume people with medical marijuana cards use the drug and not sell them firearms.

It’s illegal for a licensed firearm dealer to sell a gun to an Oregon medical or recreational marijuana consumer, said Portland lawyer Leland Berger. He noted that the ruling is focused on sales and doesn’t affect medical marijuana consumers who already have guns.

The 9th Circuit in its 3-0 decision said it was reasonable for federal regulators to assume a medical marijuana card holder was more likely to use the drug.

The court also said Congress had reasonably concluded that marijuana and other drug use “raises the risk of irrational or unpredictable behavior with which gun use should not be associated.”

“The notion that cannabis consumers are violent people is absurd,” Berger said, calling the notion that classifying medical card holders who use marijuana to treat debilitating medical conditions as violent people is “even more absurd.”

Paul Armentano, deputy director of NORML, a nonprofit that works to reform marijuana laws, called on Congress to “amend cannabis’ criminal status in a way that comports with both public and scientific opinion, as well as its rapidly changing legal status under state laws.”

“Responsible adults who use cannabis in a manner that is compliant with the laws of their states ought to receive the same legal rights and protections as do other citizens,” he said in a statement published on the nonprofit’s website.

Wilson’s attorney, Chaz Rainey, said there needs to be more consistency in the application of the Second Amendment. He planned to appeal the decision and his options include submitting the appeal to the same panel of judges that issued the ruling, a larger panel of the circuit court or the U.S. Supreme Court.

“We live in a world where having a medical marijuana card is enough to say you don’t get a gun, but if you’re on the no fly list your constitutional right is still protected,” he said.

The 9th Circuit also rejected other constitutional challenges to the ban that were raised by Wilson, including her argument that her gun rights were being stripped without due process.

Armentano said the idea that marijuana users were more prone to violence is a fallacy.

“Responsible adults who use cannabis in a manner that is compliant with the laws of their states ought to receive the same legal rights and protections as other citizens,” he said.

Alex Kreit, a marijuana law expert at Thomas Jefferson School of Law in San Diego, said the ruling was significant — but may not be the last time the 9th Circuit addresses medical marijuana and gun rights.

“It seems like the court did not foreclose the possibility of a challenge by actual medical marijuana users that they shouldn’t be lumped with other drug users in terms of concerns about violence,” he said.

— The Associated Press

Jim Ryan of The Oregonian/OregonLive staff contributed to this report