A US Army veteran has been arrested as he was in the final stages of a plan to bomb a white supremacist rally in California, say authorities.
Muslim convert Mark Domingo, 26, also allegedly plotted terror attacks on Jews, churches and police in revenge for the New Zealand mosque shootings.
He was held on Friday after accepting what he believed to be a live bomb, delivered by undercover officers.
Mr Domingo had expressed support for violent jihad, say prosecutors.
According to court documents, the former infantryman with combat experience in Afghanistan took steps to build and detonate a weapon of mass destruction.
"This investigation successfully disrupted a very real threat posed by a trained combat soldier who repeatedly stated he wanted to cause the maximum number of casualties," said federal prosecutor Nick Hanna in a statement on Monday.
In online posts and in conversations with an FBI source - posing as an accomplice - Mr Domingo expressed a desire to seek retribution for the March attacks on two mosques in Christchurch, New Zealand, and other attacks against Muslims.
He allegedly expressed a willingness to become a "martyr" in an attack.
According to authorities, Mr Domingo considered targets including Jewish people, churches and police officers, before settling on the Long Beach rally.
A far-right group had planned to march on Sunday at Bluff Park in Long Beach, though they did not show up. Anti-racism counter-demonstrators did, however, attend.
The idea to target the Long Beach event was allegedly discussed during a meeting on 19 April between Mr Domingo and the FBI agent.
Mr Domingo arrived at the meeting with an AK-47-style rifle to show he was "serious" about his plans, said prosecutors.
He also allegedly mentioned the 2013 Boston Marathon bombing, and said he wanted a device that could cause 50 casualties.
Mr Domingo also allegedly contemplated bombing the Santa Monica Pier, where he said a summer attack on the crowded tourist spot would cause maximum casualties.
Prosecutors say he referred to the October 2017 mass shooting in Las Vegas - the deadliest such attack in modern US history, it left 58 dead - as a blueprint for his own assault.
He posted online that "America needs another Vegas event" in order to "give them a taste of the terror they gladly spread all over the world", said prosecutors.
According to court documents, once Mr Domingo determined the location of his attack, he worked with the FBI source to find a bomb-maker.
The suspect planned to plant home-made explosive devices made with nail-filled pressure cookers that would be remotely triggered or detonated by a timer.
He allegedly purchased "several hundred nails" meant to be used as shrapnel inside the improvised explosive device.
"Domingo said he specifically bought three-inch nails because they would be long enough to penetrate the human body and puncture internal organs," the affidavit says.
In discussions with the FBI agent, Mr Domingo allegedly claimed that if the Islamic State were to come to the US "he would swear allegiance" to the group.
On Thursday, after purchasing the nails, Mr Domingo allegedly sent a message to the undercover agent indicating that the bombing was to proceed.
The FBI operative then delivered several "inert devices", which Mr Domingo purportedly believed to be weapons of mass destruction.
Authorities said that Mr Domingo had travelled to Long Beach to inspect the site of the bombing when he was taken into custody.
In a joint statement, federal authorities celebrated the thwarting of the alleged attack and said there was no outstanding threat to the public.
If convicted, Mr Domingo could face a maximum sentence of 15 years in federal prison.