Samy Mohamed Hamzeh was arrested Monday after buying two automatic weapons and a silencer from undercover agents, the U.S. attorney's office for the Eastern District of Wisconsin said in a statement.
The investigation thwarted an attack "that could have resulted in significant injury and/or loss of life," FBI Special Agent in Charge Robert J. Shields said in a statement announcing the arrest.
It was not immediately clear whether Hamzeh has retained legal representation.
A criminal complaint released by prosecutors alleges that Hamzeh toured a Masonic center in Milwaukee this month with two FBI informants and then detailed plans for an attack in a meeting with them later that night.
Hamzeh allegedly said he was defending Islam and that he hoped to kill at least 30 people, according to the complaint.
The complaint contains chilling excerpts of comments allegedly made by Hamzeh, captured in a recording and translated from Arabic into English.
"If I got out, after killing thirty people, I will be happy 100% ...100% happy, because these 30 will terrify the world," he said at one point, according to the complaint.
At another point in the conversation, Hamzeh allegedly discussed the roles he and other attackers would play.
"One of us will stay at the door at the entrance and lock the door down, he will be at the main door down, two will get to the lift up, they will enter the room, and spray everyone in the room. The one who is standing downstairs will spray anyone he finds. We will shoot them, kill them and get out," Hamzeh said, according to the complaint.
"We will walk and walk, after a while, we will be covered as if it is cold, and we'll take the covers off and dump them in a corner and keep on walking, as if nothing happened, as if everything is normal."
Hamzeh attended Milwaukee Area Technical College from fall 2011 through last spring, school spokeswoman Kathleen Hohl told CNN.
FBI agents had been investigating him since September after a source reported he was planning to conduct an attack on Israelis in the West Bank, according to the complaint.
"Hamzeh abandoned these plans for family, financial, and logistic reasons. Thereafter, Hamzeh refocused his plans on an attack in the United States," the complaint alleges.
The FBI began monitoring and recording Hamzeh's conversations with the informants in October, according to the complaint.
Milwaukee Mayor Tom Barrett said he learned of Hamzeh's arrest from the U.S. prosecutor in the case.
"He made it clear to me that this was a serious issue. This was something that was not a casual conversation with me," the mayor said. "I got the sense that this was a real threat."
Barrett praised federal authorities for acting quickly and decisively.
"This is a situation where people should sit up, take notice, be thankful," he said.