ELMWOOD PARK, N.J. -- Two New Jersey men who envisioned a terrorist attack in the U.S. with a body count twice that of the Fort Hood massacre were arrested at a gate New York's Kennedy Airport as they were about to board flights on their way to Somalia to seek terror training from al-Qaida-affiliated jihadists, officials said.

Mohamed Mahmood Alessa, 20, and Carlos Eduardo Almonte, 24, were arrested Saturday before they could board separate flights to Egypt and then continue on to Somalia, federal officials in New Jersey and the New York Police Department said.

Law enforcement became aware of the men in the fall of 2006, after receiving a tip. New York Police Commissioner Raymond Kelly said they had traveled to Jordan in 2007 and tried to get into Iraq, but were turned back by their would-be recruiters.

Since then, during the lengthy investigation, an NYPD undercover officer recorded conversations with the men in which they spoke about jihad against Americans.

"I leave this time. God willing, I never come back," authorities say Alessa told the officer last year. "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."

Alessa also was allegedly recorded telling Almonte that he would outdo Maj. Nidal Hasan, the Army psychiatrist accused of killing 13 people at Fort Hood, Texas, last year.

"He's not better than me. I'll do twice what he did," Alessa allegedly said.

Kelly said Alessa of North Bergen, and Almonte of Elmwood Park, are American citizens. Alessa was born in the United States and is of Palestinian descent. Almonte is a naturalized citizen who was born in the Dominican Republic.

They are the latest of many Americans or immigrants to the U.S. accused of joining or trying to join al-Shabab, a violent extremist group based in Somalia and connected to al-Qaida. Al-Shabab was designated by the U.S. as a terrorist group in 2008.

Investigators say they're also among many U.S. terrorism suspects to have been inspired by two well-known U.S. citizens who have recruited terrorists through the Internet: Adam Gadahn, an al-Qaida spokesman in Pakistan, and Anwar al-Awlaki, a radical al-Qaida cleric hiding in Yemen who is believed to have helped inspire recent attacks including the Fort Hood shooting, the Times Square bombing attempt and the failed Christmas Day airline bombing.

Both men have made public calls for smaller, single acts of terrorism and court documents show Alessa and Almonte appearing to be inspired by that idea.

Alessa and Almonte face charges of conspiring to kill, maim, and kidnap persons outside the United States by joining al-Shabab. Teams of state and federal law enforcement agents who have been investigating the men took them into custody, authorities said. They are scheduled to appear today in federal court in Newark.

While court documents paint a picture of two men deeply committed to terrorism, their training apparently was scattershot. They lifted weights, hiked in the snow at a local park, bought military-style pants and water bottles, played violent video games and watched terrorist videos online. They had no known connections to terrorist groups, and their trip to Somalia apparently amounted to a leap of faith that they'd be embraced by the group.

Court documents do not indicate that authorities had other targets in the investigation. In March, Alessa was recorded telling Almonte and the undercover officer that no one else they knew in New Jersey should be included in their plan to join al-Shabab because only the three of them were "serious about their plan and were preparing for it."

Kelly on Sunday cited the "excellent work" done by the undercover officer, who Kelly said was of Egyptian descent and in his mid-20s. The officer joined the department in 2005.

The men said they planned to get weapons when they went abroad. The only weapons they possessed were two folding knives Alessa said he would use to kill police if they tried to get near him: "I'm-a cut them in half with it, even if I die," Alessa said, according to court documents.

Alessa and Almonte had planned their trip to Somalia for several months, saving thousands of dollars, officials said. Both had bragged about wanting to wage holy war against the United States both at home and internationally, according to a criminal complaint. Officials said the two men were not planning an imminent attack in the New York-New Jersey area and weren't suspected of plotting any violence on their flights.