NEWARK, New Jersey -- A federal magistrate has denied bail for two New Jersey men accused of trying to join a terrorist group in Somalia.

Prosecutors say Mohamed Mahmood Alessa and Carlos Eduardo Almonte conspired to kill, harm and kidnap persons outside the United States.

In denying bail Thursday, U.S. Magistrate Madeline Cox Arleo cited the severity of the charge and the risk of flight.

The two were arrested Saturday night at New York's Kennedy Airport as they prepared to fly to Egypt. Prosecutors say the men intended to head to Somalia to seek terror training from Al Qaeda-affiliated jihadists.

Court documents say the men had no contact with Somali terrorists and they had hoped they would be accepted by a terrorist group.