Eritrean pleads guilty to aiding
Al-Shabab still controls much of the country but is under pressure on several fronts
Mohamed Ibrahim Ahmed, a resident in Sweden, went to Somalia in 2009 to learn bomb-making and detonation skills, the US Attorney's Office said.
He also contributed 3,000 euros ($3,769, £2,433) to the Islamist mlitants, court documents revealed.
Al-Shabab, which joined al-Qaeda earlier this year, is fighting a UN-backed government in Somalia.
The 38-year-old man could face a maximum sentence of 10 years in jail and will be sentenced in November.
Ahmed was arrested in Nigeria in November 2009 and transferred to US custody four months later.
"Mohamed Ibrahim Ahmed travelled a long way from his home in Sweden to Somalia, where he took up the cause of al-Shabab, a deadly terrorist organisation and sworn enemy of the United States and its people," Manhattan US Attorney Preet Bharara said in a statement.
The rifle and its ammunition were subsequently given to al-Shabab commander.
Al-Shabab is known to have recruited a number of foreign fighters - many of whom have fought in Iraq and Afghanistan.
Last week, the US government offered millions of dollars in rewards for information leading to the capture of seven al-Shabab leaders.
Among those it is seeking is the Swedish Somali Fuad Mohamed Khalaf, also known as Shongole, who is the group's financier.
Somalia has had no effective central government since 1991, and has been wracked by fighting ever since - a situation that has allowed piracy and lawlessness to flourish.
Source: BBC News