NEW YORK (AP) — A U.S. citizen living in Egypt sought to join the al Shabaab terrorist organization and wage violent jihad against America and its allies in the wake of Hamas’ Oct. 7 attack on Israel, federal prosecutors said Friday.

Karrem Nasr, 23, of Lawrenceville, New Jersey, was arrested Dec. 14 after flying from Egypt to Nairobi, Kenya, where prosecutors say he was planning to meet with al Shabaab members before traveling to train in Somalia, where the terror group is based.

Nasr was returned to the U.S. on Thursday and was scheduled to appear Friday before a federal magistrate in Manhattan. He is charged with attempting to provide material support to a designated foreign terrorist organization. He faces up to 20 years in prison if convicted.

Court records did not list a lawyer who could speak on Nasr’s behalf.

Nasr, also known as Ghareeb Al-Muhajir, expressed his desire to join al Shabaab in online postings and communications with a paid FBI informant who was posing as a facilitator for terrorist organizations, according to a criminal complaint unsealed Friday.

Nasr told the informant “the No. 1 enemy is America,” which he described as the “head of the snake,” the complaint said. He posted on X, formerly known as Twitter, that jihad was “coming soon to a US location near you,” the complaint said. The post, under the name “Egyptian Muslim,” included airplane, bomb, and fire emojis.

Nasr, who moved to Egypt in July, started communicating with the FBI informant in November via an encrypted messaging app, according to the criminal complaint. He told the informant that he had been thinking of waging jihad “for a long time” but that he was “not capable of doing it” before Hamas attacked Israel, the complaint said.

“After the October 7th events, I felt that something has changed,” Nasr told the informant, according to the complaint. “To the better, I mean. I felt that pride and dignity came back to the Muslims.”

The U.S. designated al Shabaab a foreign terrorist organization in 2008.

The group evolved from a coalition of Islamic insurgents that fought Somalia’s fledgling central government and seized control of large swaths of territory in the early 2000s. It has been blamed for myriad violence, including suicide bombings, a beheading and the targeted assassinations of civilians and journalists.

Somalia’s President Hassan Sheikh Mohamud has pledged to wipe out al Shabaab within a year. The group has been losing territory since the government, backed by local militias, African Union troops and Western powers, launched an extensive offensive against it in May.