A man from Uzbekistan who pleaded guilty to plotting to kill US president Barack Obama with an automatic rifle claimed he was acting at the direction of an Islamic terror group in his home country.
Authorities said Ulugbek Kodirov had discussed trying to kill the president as he campaigned for re-election because he would be out in public more often.
Kodirov entered the plea during a hearing in Birmingham, Alabama before US District Judge Abdul K Kallon.
Defence attorney Lance Bell said the 22-year-old Kodirov avoided a potential life sentence by pleading guilty.
He faces up to 30 years in prison, though Mr Bell expected Kodirov to receive about half that. The judge also told Kodirov that he will face deportation once he is released from prison.
Kodirov pleaded guilty to three counts: Threatening to kill the president, possessing an automatic weapon, and providing material support to terrorists. Four other charges were dropped as part of the deal.
Muslims in the Birmingham area who knew Kodirov were stunned to learn of his plans.
"I really didn't want to believe it," said Ashfaq Taufique, president of the Birmingham Islamic Society.
"I knew him. He attended mosque. He never demonstrated any radicalisation in his behaviour, his words."
US attorney Joyce Vance said members of the Islamic community assisted in the case against Kodirov.