A US veteran of the war in Afghanistan who prosecutors say plotted to detonate a nail bomb at a Los Angeles-area white nationalist rally, hoping to cause mass casualties, has been arrested following an FBI online sting operation, federal prosecutors said.

Mark Steven Domingo, 26, a US Army infantry man who served in Afghanistan and later converted to Islam, was taken into custody yesterday after being given what he thought was a live explosive device to use in the attack, federal prosecutors said in a written statement.

"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," US Attorney Nick Hanna said in the statement.

Steven Domingo was charged in a federal criminal complaint with providing and attempting to provide material support to terrorists. 

Prosecutors say that in online conversations with an undercover FBI source, Mr Domingo expressed support for a violent jihad and expressed willingness to become a martyr.

Mr Domingo told the undercover operative that he planned to detonate an improvised explosive device at a rally scheduled to take place this weekend in the Los Angeles suburb of Long Beach, and asked for help in obtaining a bomb.

In an FBI affidavit filed in the case, Mr Domingo said he specifically purchased three-inch nails because they would be long enough to penetrate the human body and puncture internal organs.

He could face a maximum sentence of 15 years in federal prison if convicted of all of the charges.

The announcement comes two days after a gunman opened fire in a San Diego-area synagogue, killing one person and wounding three others.

A suspect identified as John Earnest, 19, was taken into custody in the shooting.

There was no indication that the two incidents were connected.