A federal judge in California on Thursday blocked a state law that would have barred gun owners from possessing high-capacity ammunition magazines.

San Diego-based U.S. District Judge Roger Benitez ruled that the ban approved by the Legislature and voters last year takes away gun owners' Second Amendment rights and amounts to the government taking people's private property without compensation.

"Hundreds of thousands, if not millions, of otherwise law-abiding citizens will have an untenable choice: become an outlaw or dispossess one's self of lawfully acquired property," Benitez wrote.

California law has prohibited buying or selling the magazines since 2000, but until now allowed those who had them to keep them.

He issued a preliminary injunction blocking the law from taking effect while he considers the underlying lawsuit filed by the National Rifle Association-affiliated California Rifle & Pistol Association.

“The State of California’s desire to criminalize simple possession of a firearm magazine able to hold more than 10 rounds is precisely the type of policy choice that the Constitution takes off the table,” the injunction read.

Meanwhile, a Sacramento-based judge on Thursday rejected a similar challenge by several other gun owners' rights organizations, creating what Ari Freilich, staff attorney at the Law Center to Prevent Gun Violence, called "dueling opinions" that may be sorted out on appeal.

"Unfortunately this law will be delayed but we are confident it will go into effect, and soon," he said.

He called the San Diego lawsuit and ruling part of an effort by the NRA "to delay and dismantle California's law brick by brick."

Had the ban taken effect, owners would have been required to get rid of their magazines by sending them out of state, altering them to hold no more than 10 bullets, destroying them or turning them into law enforcement agencies. Possession could have been punished by $100 fines or up to a year in jail.

Owners can now keep the magazines until a final ruling by Benitez or if an appeals court overturns his injunction, said Chuck Michel, attorney for the NRA and the California Rifle & Pistol Association.

"This court recognized that the Second Amendment is not a second-class right and that law-abiding gun owners have the right to own these magazines to defend themselves and their families," Michel said.

State lawmakers approved the ban last year as part of a package of bills adding to what already were some of the nation's strictest gun laws. Voters agreed in November when they approved Proposition 63, a measure that toughened the penalties by allowing violators to be fined or jailed.

Benitez said he was mindful of voters' approval and government's legitimate interest in protecting the public but added that the "Constitution is a shield from the tyranny of the majority."

Gun owner's constitutional rights "are not eliminated simply because they possess `unpopular' magazines holding more than 10 rounds," he wrote in a 66-page decision.

California Attorney General Xavier Becerra criticized the decision but did not say what he will do next.

"Proposition 63 was overwhelmingly approved by voters to increase public safety and enhance security in a sensible and constitutional way," Becerra said in a statement. "I will defend the will of California voters because we cannot continue to lose innocent lives due to gun violence."

Supporters say that magazines often holding 30 or 100 bullets are typically used in mass shootings and aren't needed by hunters or civilian owners.

"Clearly it escalates the lethality in any mass shooting when high-capacity magazines are involved," said Amanda Wilcox, a spokeswoman for the California chapters of the Brady Campaign to Prevent Gun Violence whose daughter was fatally shot.

Forcing assailants to change magazines more frequently gives victims time to flee or subdue the shooter, Becerra argued in court filings.

Moreover, the government wouldn't own the magazines in the way it would property seized for a new highway or public building, he argued, since the magazines would be destroyed by law enforcement agencies.

Becerra said opponents' Second Amendment challenge has repeatedly been rejected by other courts, allowing at least seven other states and 11 local governments to already restrict the possession or sale of large-capacity ammunition magazines.

The Associated Press contributed to this report