Image caption Shaker Masri was arrested hours before leaving the US

A US man accused of attempting to join hardline Islamist group al-Shabab in Somalia has pleaded guilty to charges in a US court.

Shaker Masri, 28, was arrested in August 2010 as he prepared to travel to Somalia to join al-Shabab, according to US prosecutors.

The US and UK consider the organisation, which has links to al-Qaeda, a terrorist group.

Under a plea deal, Masri has agreed to serve just under 10 years in prison.

He admitted to plotting to raise the funds he needed to engage in jihad in either Somalia or Afghanistan.

He had faced a maximum of 15 years in prison.

Masri was born in Alabama and lived in Chicago prior to his arrest just hours before leaving the country.

He had been confiding in an undercover FBI agent and had talked about targeting "infidels".

Following his arrest he was charged with attempting to provide material support to a terrorist group, and trying to offer material support by use of a weapon of mass destruction.

The full details of the plea bargain have not been made public.

Al-Shabab is believed to have recruited Somali-Americans to take part in suicide bombings in Somalia, and US officials are now increasingly concerned about the potential for an attack within the US.

Dozens of US citizens have been arrested in recent years for trying to participate in or support the two-decade long civil war.

Shaker Masri will be formally sentenced on 16 October.