(CNN)A federal appeals court struck down a California law prohibiting sales of semiautomatic firearms to anyone under 21 years of age, according to a decision filed Wednesday.
The law, which had been in effect since July 1, 2021, also restricted purchases of semiautomatic weapons to one per month for all ages.
Judge Ryan D. Nelson of the Ninth Circuit Court of Appeals said in his opinion that the law infringed on the Second Amendment rights of those ages 18 to 21.
"America would not exist without the heroism of the young adults who fought and died in our revolutionary army. Today we reaffirm that our Constitution still protects the right that enabled their sacrifice: the right of young adults to keep and bear arms," Nelson wrote.
Judge Kenneth K. Lee concurred, writing, "We cannot allow good intentions to trump an enumerated and 'fundamental right' deeply rooted in the history and tradition of this country."
State Attorney General Rob Bonta's office said it was reviewing the 2-1 decision.
"California will continue to take all necessary steps to prevent and reduce gun violence. We remain committed to defending California's commonsense gun laws, which save lives and make our communities safer," a statement from his office read.
The Firearms Policy Coalition, a gun rights nonprofit, was among the groups that brought the case.
"Today's decision confirms that peaceable legal adults cannot be prohibited from acquiring firearms and exercising their rights enshrined in the Second Amendment," Adam Kraut, coalition vice president of programs, said in a statement.
The decision did not affect an existing California law that requires adults over 18 but under 21 years of age to have a valid hunting license to purchase rifles or shotguns.
California Sen. Anthony Portantino, who authored both bills, said in a statement to CNN, "Though I'm disappointed to have the semiautomatic centerfire rifle provisions struck down by the court, I'm pleased that the general provisions of SB 1100, raising the firearm purchase age to 21, is still the law in California. I remain committed to keeping deadly weapons out of the wrong hands. Student safety on our campuses is something we should all rally behind and sensible gun control is part of that solution."