Gov. Phil Murphy signed a gun control bill into law Thursday that bans "ghost guns" that can be assembled with untraceable components at home.

The measure, which also outlaws controversial 3D-printable guns in the Garden State, gives New Jersey the distinction of having the nation's toughest ban on the untraceable firearms, the governor said.

"We're here to close a dangerous loophole in our gun laws and to expressly outlaw so-called ghost guns here in New Jersey," Murphy, at a news conference Thursday in Trenton, said.

"Anyone possessing a homemade or 3D printed firearm ... will be prosecuted to the fullest extent of the law and face up to five years in prison," he said.

He put his signature on the new law fewer than 24 hours after the nation's most recent mass shooting in California, where a Marine combat veteran killed 12 people, including a veteran sheriff's officer.

The gunman has been identified as 28-year-old Ian David Long, a former machine gunner and decorated veteran of the war in Afghanistan. He opened fire during college night at a country music bar.

Murphy called the latest mass shooting another reminder of the horror of gun violence.

"Mass murder is not the price that we have to pay for the Second Amendment," Murphy said.

It was the nation's deadliest such attack since 17 students and teachers were killed at a Parkland, Florida, high school nine months ago. It also came less than two weeks after a gunman massacred 11 people at a synagogue in Pittsburgh.

The law Murphy signed (S2465) makes it illegal to purchase firearm parts for assembly and manufacturing and possessing untraceable firearms.

Gun-rights advocates say the measure is redundant because it's already against state law to manufacture a firearms without a state manufacturer's license and that people prohibited from buying guns are also barred from assembling guns.

Attorney General Gurbir Grewal said Thursday that the state has relied on other gun laws to target manufacturers of gun laws but that this law is a more precise tool.

Murphy said Thursday the law is effective immediately.

It's the latest law the state's Democratic freshman governor has signed to tighten the state's already strict gun laws as he's vowed to make New Jersey a national leader on gun control.

3D-printable guns became the subject of a national debate this summer when a Texas man, Cody Wilson, said he planned to publish schematics for homemade guns online.

In New Jersey, Murphy's administration got involved in nation-wide lawsuits to stop him.

Grewal in June sent cease and desist letter to companies advertising online for the sale of "unregistered and unserialized firearms -- including assault weapons -- constructed, at least in part, by the purchaser."

Grewal on Thursday declined to disclose the names of the letter's recipients, saying while some had complied, others had not.

NJ Advance Media Staff Writers Samantha Marcus and Brent Johnson and The Associated Press contributed to this report.

Matt Arco may be reached at marco@njadvancemedia.com. Follow him on Twitter @MatthewArco or Facebook.