A Yemeni man has pleaded guilty to U.S. charges that he joined al-Qaida to attack American forces overseas.

Ali Alvi al-Hamidi entered the plea on Tuesday in federal court in Brooklyn.

The 31-year-old al-Hamidi was detained in Saudi Arabia before being brought to the U.S. a year ago to face conspiracy charges. Prosecutors accused him of traveling to Pakistan to get military training from al-Qaida before fighting against U.S. troops in Afghanistan, and of helping an American from Long Island join the terror group.

He faces a possible life prison term at sentencing on June 3.