Two California counties violated the Constitution’s right to keep and bear arms when they shut down gun and ammunition stores in 2020 as nonessential businesses during the coronavirus pandemic, a federal appeals court ruled Thursday.

Officials in Los Angeles and Ventura counties had separately won lower court decisions saying gun stores were not exempt from broader shutdown orders aimed at limiting the spread of the coronavirus early in the pandemic.

A three-judge panel of the 9th U.S. Circuit Court of Appeals rejected both lower court rulings.

The Second Amendment “means nothing if the government can prohibit all persons from acquiring any firearm or ammunition,” Judge Lawrence VanDyke wrote. “But that’s what happened in this case.”

Because buyers can obtain guns only by personally going to gun stores in California, Ventura County’s 48-day closure of gun shops, ammunition shops and firing ranges “wholly prevented law-abiding citizens in the County from realizing their right to keep and bear arms,” he wrote.

This, he noted, while bike shops were among those allowed to remain open as essential businesses. The panel adopted the same reasoning in the Los Angeles County case, though the closure there was for 11 days.

Three gun-owner rights groups and several individuals and businesses had sought to overturn the lower court rulings.

Los Angeles County Sheriff Alex Villanueva, Los Angeles Mayor Eric Garcetti—named plaintiffs in the case—did not immediately comment, nor did Ventura County officials.

Fight sparks SWAT standoff at Downtown church’s homeless shelter