A US man who plotted to attack a Masonic temple and “annihilate” everyone inside was arrested on gun charges, officials said Tuesday.

Samy Mohamed Hamzeh, 23, had been under investigation by the FBI since September after an informant tipped them off to his plans to attack Israeli soldiers in the West Bank.

Hamzeh — who lives in Milwaukee, Wisconsin — “abandoned these plans for family, financial and logistic reasons” and then “refocused his plans on an attack in the United States,” charging papers said.

ADVERTISEMENT

“It is difficult to calculate the injury and loss of life that was prevented by concerned citizens coming forward and by the tireless efforts of the FBI and the Joint Terrorism Task Force,” US Attorney Gregory Haanstad said in a statement.

“Samy Mohamed Hamzeh devised a detailed plan to commit a mass shooting intended to kill dozens of people. He also said that he wanted this mass shooting to be ‘known the world over’ and to ‘ignite’ broader clashes.”

Two informants worked with the FBI to record his plans. They went to a firing range with him on January 19 and then took a guided tour of the Masonic temple.

After they left, Hamzeh spoke of how he hoped to kill at least 30 people in order to “terrify the world.”

“I am telling you, if this hit is executed, it will be known all over the world,” he allegedly said in a conversation translated from Arabic.

ADVERTISEMENT

“Sure, all over the world, all the mujahedeen will be talking and they will be proud of us,” he allegedly said, referring to fighters engaged in jihad, or holy war.

“Such operations will increase in America, when they hear about it. The people will be scared and the operations will increase, and there will be problems all over.

“This way we will be igniting it. I mean, we are marching at the front of the war.”

ADVERTISEMENT

Hamzeh said they would need three machine guns with silencers to carry out the attack and that the man who stood at the door has a “bigger responsibility” and has to “annihilate everyone.”

He had planned to escape by killing everyone quickly and quietly and by hiding their faces with cold-weather gear.

ADVERTISEMENT

Hamzeh was arrested Monday after buying two automatic weapons and silencers from undercover agents.

“At no time was the public’s safety placed in jeopardy,” said Robert Shields, the FBI’s special agent in charge of the Milwaukee region.