Image caption Al-Shabab controls a large part of Somalia but has retreated from the capital Mogadishu

A former US Army soldier has been charged with trying to help Somalia's al-Shabab militant group.

Craig Baxam, 24, was arrested by Kenyan authorities in December as he tried to cross the border into Somalia.

An affidavit released by US prosecutors alleges that he planned to offer several hundred dollars to the militant group, which has links to al-Qaeda, and to serve as a fighter.

He faces up to 15 years in prison if convicted, prosecutors say.

Mr Baxam, who lives in a Maryland suburb outside Washington DC, flew to Nairobi on 20 December and attempted to travel to the Kenyan-Somali border by bus and taxi.

He was arrested by US officials when he arrived back in the country on 6 January.

The US has designated al-Shabab a terrorist group, and the group has sought to recruit Americans to fight in Somalia.

Website conversion

Mr Baxam joined the army in 2007 and was trained in intelligence and cryptology.

Al-Shabab at a glance "The Youth" in Arabic

Formed as a radical offshoot of the Union of Islamic Courts in 2006

Affiliated to al-Qaeda

Killed 76 people in double attack in Uganda during 2010 football World Cup

Estimated to have 7,000 to 9,000 fighters Q&A: Who are Somalia's al-Shabab?

He previously served in Iraq, returned home and then re-enlisted. He was deployed to South Korea for one year beginning in August 2010.

The affidavit alleges that he converted to Islam secretly after reading an Islamic website while serving in Korea.

Travelling to Somalia held appeal for Mr Baxam because he wanted to live in a country where he believed Sharia law held sway. He no longer believed he could live in the US, prosecutors say.

The only places that were acceptable, according to the affidavit, were Taliban-controlled areas of Afghanistan, part of Somalia controlled by al-Shabab, and in the southern Philippines.

Mr Baxam is quoted as saying he wanted to die "with a gun in my hand", and that he would be happy to die defending Islam.

When told that during interviews with the FBI that al-Shabab encouraged beating people who were seen in the street during prayer time, Mr Baxam allegedly replied "that is awesome".

While the affidavit does not describe exactly how Mr Baxam was found, it does say he was wary of searching for al-Shabab on his computer because he was "aware of the capabilities of the US government".

He also believed his travel towards the Somali border captured the attention of Kenyan authorities, who arrested him before US embassy and FBI officials questioned the former Army officer.

Al-Shabab announced a "tactical withdrawal" from the capital of Mogadishu last summer but in October an al-Shabab suicide bomber killed over 70 people near a government building.

In September, the US launched a series of attacks by unmanned drones on suspected al-Shabab positions around the Somali port town of Kismayo.