SACRAMENTO, Calif. — A federal judge on Friday halted sales of high-capacity ammunition magazines in California, giving state officials a chance to appeal his order last week that allowed their sale for the first time in nearly 20 years.

U.S. District Judge Roger Benitez barred further sales until the 9th U.S. Circuit Court of Appeals considers whether to reinstate the state's ban on magazines holding more than 10 bullets.

But the judge said those who bought the extended magazines since his initial order a week ago may keep them without fear of being prosecuted while the appeal proceeds.

Hundreds of thousands of gun owners may have bought the magazines since Benitez threw out the state's ban last week as infringing on their Second Amendment right to bear arms, said Chuck Michel, an attorney for the National Rifle Association and the California Rifle & Pistol Association who filed the lawsuit that led to the ruling.

Under Benitez's order, no one in California is permitted to manufacture, import, buy or sell large-capacity magazines as of 5 p.m. Friday.

California has prohibited such magazines since 2000, though people who had the magazines before then were allowed to keep them. Benitez last week threw out both the 2000 law and a 2016 law and ballot measure banning possession even by those who had owned them legally.

"All the people who bought the magazines in the last week are protected from prosecution, but any further purchase of these magazines is illegal for the moment," Michel said. "There was 20 years of pent up demand for these self-defense tools, and several hundred thousand people bought them in the last week, maybe more than several hundred thousand."

Attorney General Xavier Becerra, who sought the stay, warned in a court filing that it would be difficult for the state to remove the newly purchased magazines, even if the ban is reinstated.

Becerra cited a half-dozen mass shootings nationwide since 2011 where the killers used large-capacity magazines.

"California leads the nation when it comes to common-sense gun laws. We should all be ensuring the safety of our communities, not fighting against long-standing laws that improve public safety," Becerra said in a statement. He added that he's confident the ban is constitutional.

Benitez acknowledged in his six-page stay order that other judges, in California and elsewhere, have upheld bans on high-capacity magazines.

"The Court understands that strong emotions are felt by people of good will on both sides of the Constitutional and social policy questions. The Court understands that thoughtful and law-abiding citizens can and do firmly hold competing opinions on firearm magazine restrictions," he wrote.

"These concerns auger in favor of judicial deliberation. There is an immeasurable societal benefit of maintaining the immediate status quo while the process of judicial review takes place."