A U.S. judge has struck down a nearly century-old California law that banned gun shops from advertising handguns on their premises.

A U.S. judge on Tuesday struck down a nearly century-old California law that banned handgun ads at gun shops, saying the state failed to show it would prevent suicides or crime.

The 1923 law banned any handgun ads at gun shops that were visible from outside the store. State officials argued the ads would spur impulsive people to buy a handgun, and impulsive people are more prone to suicide and crime.

The law, however, did not restrict ads for other firearms.

Judge Troy Nunley in Sacramento noted in his ruling that gun shops could display a large neon sign reading, "GUNS GUNS GUNS" or a 15-foot depiction of a sporting rifle. The judge said they could also place ads for handguns elsewhere such as on a billboard blocks away.

"The Government may not restrict speech that persuades adults, who are neither criminals nor suffer from mental illness, from purchasing a legal and constitutionally protected product, merely because it distrusts their personality trait and the decisions that personality trait may lead them to make later down the road," Nunley said.

California has other laws that could prevent handgun violence without restricting speech in violation of the First Amendment, the judge said.

The ruling came in a lawsuit filed in 2014 by several gun dealers who were fined by the state for handgun ads.

"If you are someone who is providing a constitutionally protected product or service, you should be able to communicate that to people in the same way a bookseller should be able to advertise they sell Bibles and Qurans," said Brandon Combs, executive director of The Calguns Foundation, a gun rights group. "Dealers should be able to say they sell handguns."

A spokeswoman for the state attorney general's office, which defended the law, said the office was reviewing the decision.

The state Department of Justice cited one of the plaintiffs, Ten Percent Firearms, for a metal sign shaped like a revolver in the store's parking lot that an inspector spotted in 2010, according to Nunley's ruling. Another plaintiff, Tracy Rifle and Pistol, received a citation after an inspector in 2014 found large vinyl decals depicting three handguns on the store's windows.

"As the Court explained today, the government cannot censor commercial speech in a paternalistic effort to keep citizens from making unpopular choices - or choices the government doesn't approve - if they are told the truth," Brad Benbrook, an attorney for the plaintiffs said in a statement.