A veteran of the war in Afghanistan was arrested Friday and accused of plotting to attack a scheduled white nationalist rally over the weekend in Long Beach, Calif., federal investigators say.

Mark Steven Domingo, 26, faces one count of providing and attempting to provide material support to terrorists, according to a federal complaint unsealed Monday.

Prosecutors say Domingo made online posts that "expressed support for violent jihad, a desire to seek retribution for attacks against Muslims, and a willingness to become a martyr." Authorities added that after Domingo considered attacks targeting "Jews, churches and police officers," he decided to detonate an improvised explosive device at the Long Beach rally, which police said was called off Sunday morning.

"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 United States Attorney Nick Hanna in a statement. "Protecting Americans from terror attacks is the number one priority of the Justice Department, and anyone who plots to use a weapon of mass destruction will be held to account."

Investigators conducted an online sting operation, during which Domingo allegedly told an undercover FBI source to find a bomb-maker and purchased several hundred nails to use as shrapnel.

"Domingo said he specifically bought three-inch nails because they would be long enough to penetrate the human body and puncture internal organs," FBI Special Agent Tasha Coolidge said in an affidavit supporting the indictment.

The affidavit also alleges that Domingo posted an online video on March 2 professing his belief in Islam. The following day, he posted on an unnamed social media network that "america needs another vegas event ... to kick off civil unrest," a reference to the October 2017 mass shooting at a country music festival on the Las Vegas Strip. Domingo allegedly wrote that such an event would be "about weakening america [and] giving them a taste of the terror they gladly spread all over the world."

CLICK HERE TO GET THE FOX NEWS APP

Days later, after a white supremacist killed 50 people in shootings at two mosques in Christchurch, New Zealand, Domingo posted "there must be retribution." After that, prosecutors say the FBI source began chatting with Domingo about his plans.

Domingo said he had an assault rifle and semi-automatic rifle and discussed possible jihad attacks targeting Jews walking to synagogue, churches, police officers or a military base, according to investigators. He also allegedly discussed bombing the Santa Monica Pier and launching further attacks on the Port of Long Beach or a train if he survived his planned attack in the city's Bluff Park.

An FBI SWAT team arrested Domingo Friday after he was given the pressure cookers and surveyed the park site. The FBI source had connected him with a ppurported bomb maker who was actually an undercover police officer and the resulting contraption contained only inert materials.

"The brave men and women of the LAPD and our partners in federal law enforcement showed the world what they do every day: arrest a suspect, avert a tragedy, and save lives. Thanks to the vigilance, cooperation, and courage of our Joint Terrorism Task Force, we stopped a deadly plot in its tracks," Los Angeles Mayor Eric Garcetti said in a statement. "In the wake of Pittsburgh, Christchurch, Poway, and other evil acts driven by hate and fear, we must stand firm against all forms of bigotry, answer evil with resolve, and always act to keep Angelenos safe in their homes, communities, and sacred houses of worship."

A U.S. Army spokesperson told Fox News Domingo served as an infantryman between November 2011 and February 2013. He was deployed to Afghanistan between September 2012 and January 2013.

News of the alleged plot comes just days after a shooter opened fire in a San Diego synagogue, killing one woman and injuring several others.

The Associated Press contributed to this report.