A ban on the sale of ammunition magazines that hold more than 10 rounds has been a linchpin of California’s efforts to prevent mass shootings for nearly two decades.

But in the span of a single week after a federal judge temporarily set aside the prohibition, hundreds of thousands of the devices, if not millions, made their way into the hands of state residents, industry leaders say.

The run on high-capacity magazines from March 29 to April 5 — so fervid that online traffic from gun enthusiasts around the state crashed at least one retail website — was hailed as “Freedom Week” by the California Rifle and Pistol Association and criticized as an alarming safety breach by gun-control advocates.

The ruling in San Diego by Judge Roger Benitez, who said the sales ban on the magazines violated the Second Amendment, was stayed last week pending a challenge to the Ninth Circuit Court of Appeals. But not before it triggered a celebratory frenzy as dealers courted customers in California, many offering discounts amid a mass shift of inventory to the Golden State.

“There was a huge pent-up demand for these standard-capacity magazines,” said Chuck Michel, a lawyer for the National Rifle Association and the president of the California Rifle and Pistol Association, contending that the magazines that have been off-limits should not be referred to as “high-capacity.”

While California has long banned the retail sales of the magazines, possession of them has remained legal. Thanks to the judge’s ruling, Michel said, “hundreds of thousands of law-abiding gun owners purchased probably more than a million of these self-defense tools that had been unavailable for almost 20 years.”

Supporters of California’s gun laws, though, are cringing at what they called the partial undoing of two decades of work over seven days.

They have long sought to purge the state of high-capacity magazines, arguing that would-be mass shooters prefer them for the same reason they are popular among enthusiasts: They allow more bullets to be fired more quickly without reloading.

“I think about the numerous shootings that are often stopped when someone jumps in when the shooter is reloading,” said Josh Horwitz, executive director of the Coalition to Stop Gun Violence. “For people shot by the second magazine, it really matters.”

There are no official figures on how many of the high-capacity magazines sold after the judge’s decision. But the buying spree exposed the tension that surrounds California’s stricter gun regulations. It also underscored the fervor of gun-rights proponents, who tend to pay much closer attention to the legal fight over the issue than their opponents.

California’s ban took effect in 2000, making it illegal to buy or sell magazines that can hold more than 10 rounds. Another law, Proposition 63 — sponsored by then-Lt. Gov. Gavin Newsom and approved by the voters in 2016 — would require anyone who owns the magazines to get rid of them.

But the NRA has tied up the measure in court, winning another favorable ruling from Judge Benitez. That means that if someone purchased a high-capacity magazine during the recent brief window, they not only can keep it but use it at a California gun range.

State residents have in the past two decades found other ways to get ahold of the magazines. According to police, California residents have been known to purchase the devices in Nevada and drive them back over the border. Magazines don’t carry serial numbers, so tracking them is nearly impossible.

Brandon Combs, president of the Firearms Policy Coalition in Sacramento, which advocates for deregulation of firearms sales, said law-abiding gun owners knew the one-week grace period was an opportunity that might not come again.

“I think most people saw the news and reacted as anyone would have expected,” Combs said. “It was a normal response for what has been a closed market for almost two decades.”

One Northern California gun retailer bought $130,000 in high-capacity magazines in anticipation of a rush after the court ruling, Combs said.

Rainier Arms, an online retailer based in Washington state, told Ammoland, a news website for gun enthusiasts, that increased sales crashed its payment processing server as California customers rushed to buy Magpul Gen2 30-round magazines. Elite Tactical Components of Arizona told the website it offered a California-only sale on 30-round XTech MAG47 magazines for $10 each.

“Elite Tactical Components is excited to do our part in getting standard capacity freedom into the hands of Californians!” the company told Ammoland.

Beretta, meanwhile, offered a 20% discount on the magazines, tweeting a “Celebration Update!” to “welcome California back to the club.” News spread fast as well on online forums hosted by CalGuns.net.

“Buy lots more ammo ... or more high-capacity magazines before the 9th puts their filthy fingers into it,” one commenter wrote, referring to the Court of Appeals.

The shopping blitz didn’t extend to all Bay Area gun merchants. John Parkin, owner of Coyote Point Armory in Burlingame, held off purchasing the products from wholesalers because he worried he would be stuck with the inventory as the court case is appealed. He said he did sell a few thousand dollars worth of magazines he had in stock already for police officers, who haven’t been barred from buying them.

“The glut of (business) went to the online sellers,” Parkin said in an interview. “Because the rest of the country simply had that in stock all the time ... it was a huge boon for everyone except for us in California.”

Yalonda M. James / The Chronicle

Gabriel Casillas, owner of Elite Armory in Castro Valley, said his store refrained from selling the magazines during “Freedom Week.”

“We’re a bit on the conservative side,” Casillas said, explaining that he thought the ruling would be frozen sooner, leaving the store with shipments it couldn’t sell. Casillas said the store had “people calling nonstop, asking questions if we had them.”

The frenzy is “a concern,” said Hannah Shearer, litigation director for Giffords Law Center to Prevent Gun Violence in San Francisco. “It’s a major reason California voters in 2016 banned possession, because they had had enough of the problems.”

The man who shot and severely wounded Rep. Gabrielle Giffords in 2011 in Tuscon, while killing six others, was stopped after he spent his 33-round magazine and tried to reload. A 9-year-old girl was reportedly shot to death by the gunman’s 13th bullet.

Judge Benitez, though, began his court order listing examples of crime victims who ran out of bullets while encountering suspects.

“If a law-abiding, responsible citizen in California decides that a handgun or rifle with a magazine larger than 10 rounds is the best choice for defending her hearth and home,” he asked, “may the State deny the choice, declare the magazine a ‘nuisance,’ and jail the citizen for the crime of possession?”

Shearer called Benitez’s ruling an “extreme departure” from other judges’ findings and expects it to be struck down on appeal. But the decision cemented the judge as a heroic figure among gun enthusiasts, with one commenter on CalGuns.net offering up commemorative T-shirts.

San Francisco Chronicle staff writer Megan Cassidy contributed to this report.

Matthias Gafni is a San Francisco Chronicle staff writer. Email: mgafni@sfchronicle.com

Twitter: @mgafni