The arrests were announced in a news release issued by the office of the United States attorney for New Jersey, Paul J. Fishman, along with the F.B.I., the New Jersey Office of Homeland Security and Preparedness and the New York Police Department. The arrests were first reported early Sunday in The Star-Ledger of Newark.

The suspects, both United States citizens, physically conditioned themselves, engaged in paintball and tactical training, saved thousands of dollars for their trip, and acquired military gear and apparel, according to the complaint. They talked about what they said was their obligation to wage violent jihad, and at times expressed a willingness to commit acts of violence in the United States, the complaint said.

Image Pedro Almonte, the father of Carlos Almonte, at his home in Elmwood Park, N.J. Credit... William Perlman/The Star-Ledger

Last Nov. 29, for example, the complaint said that Mr. Alessa told Mr. Almonte and the undercover officer: “They only fear you when you have a gun and when you  when you start killing them, and when you  when you take their head, and you go like this, and you behead it on camera.” He added: “We’ll start doing killing here, if I can’t do it over there.” Mr. Alessa used the Arabic words for gun and killing, according to the complaint.

The next day, said the complaint, he told the officer: “I leave this time, God willing, I never come back. I’ll never see this crap hole. Only way I would come back here is if I was in the land of jihad and the leader ordered me to come back here and do something here. Ah, I love that.”

The complaint said that more recently, on April 25, Mr. Almonte said there would soon be United States troops in Somalia  which he called a good development because it would not be as gratifying to kill only Africans.

A law enforcement official said the undercover officer who made the secret recordings was in his 20s and was a five-year police veteran of Egyptian descent.