SACRAMENTO, Calif. — High-capacity gun magazines will remain legal in California under a ruling Friday by a federal judge who cited home invasions where a woman used the extra bullets in her weapon to kill an attacker while in two other cases women without additional ammunition ran out of bullets.

"Individual liberty and freedom are not outmoded concepts," San Diego-based U.S. District Judge Roger Benitez wrote as he declared unconstitutional the law that would have banned possessing any magazines holding more than 10 bullets.

California law has prohibited buying or selling such magazines since 2000, but those who had them before then were allowed to keep them.

In 2016, the Legislature and voters approved a law removing that provision. The California arm of the National Rifle Association sued and Benitez sided with the group's argument that banning the magazines infringes on the Second Amendment right to bear arms.

Benitez had temporarily blocked the law from taking effect with a 2017 ruling.

Chuck Michel, an attorney for the NRA and the California Rifle & Pistol Association, said the judge's latest ruling may go much farther by striking down the entire ban, allowing individuals to legally acquire high-capacity magazines for the first time in nearly two decades.

"We're still digesting the opinion but it appears to us that he stuck down both the latest ban on possessing by those who are grandfathered in, but also said that everyone has a right to acquire one," Michel said.

Attorney General Xavier Becerra said in a statement that his office is "committed to defending California's common sense gun laws" and is reviewing the decision and evaluating its next steps.

Becerra previously said similar Second Amendment challenges have been repeatedly rejected by other courts, with at least seven other states and 11 local governments already restricting the possession or sale of large-capacity ammunition magazines. The conflicting decisions on extended magazines may ultimately be sorted out by the U.S. Supreme Court.

Michel said the decision "recognizes that the Second Amendment is not a second-class right and that the state has to meet a high burden before it can pass a law that infringes on the right to keep or bear arms," Michel said.

Benitez described three home invasions, two of which ended with the female victims running out of bullets.

In the third case, the pajama-clad woman with a high-capacity magazine took on three armed intruders, firing at them while simultaneously calling for help on her phone.

"She had no place to carry an extra magazine and no way to reload because her left hand held the phone with which she was still trying to call 911," the judge wrote, saying she killed one attacker while two escaped.

He ruled that magazines holding more than 10 rounds are "arms" under the U.S. Constitution, and that the California law "burdens the core of the Second Amendment by criminalizing the acquisition and possession of these magazines that are commonly held by law-abiding citizens for defense of self, home, and state."

The goal of the California law is to deter mass-shootings, with Becerra previously listing as an example the terrorist assault that killed 14 and injured 22 in San Bernardino.

Benitez, an appointee of Republican President George W. Bush, called such shootings "exceedingly rare" while emphasizing the everyday robberies, rapes and murders he said might be countered with firearms.

Both the magazine ban and new assault weapon restrictions were included in legislation, but voters strengthened penalties for the magazine ban with their approval in 2016 Proposition 63, which also included other gun control measures and was championed by then-Lt. Gov. Gavin Newsom.

Gov. Newsom did not comment Friday.