Two American men arrested as they allegedly tried to fly to Somalia to join a terrorist group made their first appearance in federal court Monday.

Mohamed Mahmood Alessa and Carlos Eduardo Almonte are accused of trying to join al-Shabab, which was designated by the U.S. as a terrorist group in 2008. They face charges of conspiring to kill, maim and kidnap persons outside the United States.

The 20-year-old Alessa and the 24-year-old Almonte appeared briefly Monday in U.S. District Court in Newark. Both had curly dark hair and bushy beards and had their feet and hands shackled.

They spoke only to say they understood the charge against them. Both remained in custody pending a bail hearing Thursday.

If convicted, the two men could face life in prison.

Though the alleged plot was arrested before the two men boarded separate Egypt-bound flights from New York's John F. Kennedy International Airport, federal officials said the two posed a threat to American citizens abroad.

"Sophistication is not necessarily a measure of danger, as we've learned in lots of other cases," U.S. attorney Paul Fishman said outside the courthouse Monday. "I think that we would be remiss if we didn't pay attention to anyone who has the intention to do what these folks are alleged to have done, which is to seek to join a violent jihad to commit acts of violence against people here or abroad."

New York City Police Commissioner Raymond Kelly told reporters Sunday that the young men had traveled to Jordan in 2007. From there, they tried to get into Iraq but were turned back, he said. 

"It's not unlike other cases that we've seen recently where individuals who express an interest to do 'jihad' go overseas and then are turned around" and "come back to attempt acts of violence in the United States," Kelly said, citing other high-profile cases, like Najibullah Zazi and Faisal Shahzad, both charged with plotting separate acts of terror inside the United States.

State and federal law enforcement agents have been investigating Alessa, of North Bergen, and Almonte, of Elmwood Park, since 2006, intercepting several conversations between the two about beheading Americans and committing acts of terror.

On Nov. 29, 2009, authorities recorded a conversation between Alessa and Almonte in which Alessa allegedly said: "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."

"We'll start doing killing here. If I can't do it, over there," Alessa said, according to the U.S. District Attorney's office.

Speaking of Fort Hood shooter Maj. Nidal Malik Hasan, charged with killing 13 people and wounding scores of others in a Nov. 5, 2009, massacre, Alessa allegedly told an undercover agent: "He's not better than me. I'll do twice what he did."

Almonte reportedly told the undercover officer in April that there would soon be American troops in Somalia, which he allegedly said was good because it would not be as gratifying to kill only Africans.

"My soul cannot rest until I shed blood," Alessa said, according to court documents. "I wanna, like, be the world's known terrorist."

Alessa, a U.S. citizen of Palestinian descent, and Almonte, a naturalized U.S. citizen born in the Dominican Republican, are scheduled to appear Monday in federal court in Newark.

Alessa and Almonte had planned their trip to Somalia for several months, saving thousands of dollars, undergoing tactical training and test runs at paintball fields to condition themselves physically, and acquiring equipment and clothing they could use when they joined al-Shabab, officials said. Both had reportedly bragged about wanting to wage holy war against the United States both at home and internationally.

Officials said the two men were not planning an imminent attack in the New York-New Jersey area.

A neighbor of Alessa's, Helen Gonyou, said Alessa was attending school and lived with his parents but that she had not seen him in a while. They are good neighbors, she said, adding that she regularly exchanged pleasantries with Alessa's father.

She cautioned against prejudgment and called the charges an "unfortunate set of circumstances."

"I just have to hope that if the case is true, they caught them before they could do bodily harm to anyone," she said.

Fox News' David Lee Miller and the Associated Press contributed to this report