In the years after 9/11 the threat to America from Islamist militants seemed to come exclusively from abroad, but recent events have disproved that assumption - and posed the question how to prevent the radicalisation of Muslim immigrants.

Image caption Omar Hammami learned about his Muslim background on a visit to Syria as a teenager

The town of Daphne in the state of Alabama is one of the last places you would associate with violent jihad.

It is a place of ease and comfort, tidy and prosperous. Large houses sit well back from the road, sprawling lazily in the trees in the warm spring sunshine. In front of many homes and shops the Stars and Stripes hangs, barely moving in the late afternoon stillness.

Here Omar Hammami grew up, an all-American boy, baptised and church-going.

Here he discarded his upbringing and religion and turned to an ever more orthodox Islam.

And here he began a journey that has taken him to the wilds of Somalia, and a high profile position in al-Shabab, the brutal Islamist insurgent group.

Syria visit

Few would have predicted it.

"His dad is Syrian, a Sunni Muslim, his mom's a Southern Baptist, from a little tiny town down here. His mom would take him to church and stuff like that," his schoolfriend, James Culveyhouse, explains.

Omar Hammami was popular at school, quick witted and charismatic, elected president of his school year.

Find out more American Jihad is on BBC Radio 4 on 19 April at 2000 BST

And on 24 April at 1700 BST

You can also listen on the iPlayer Listen on the iPlayer

Things started to change when Hammami visited Syria as a teenager.

"When he went on vacation he started to realise, I'm not just American, I've got this other side to me. He read more and more and by the time he was 15 he was like, 'I wanna be a Muslim,'" Culveyhouse says.

Over the years Omar Hammami became an adherent of stricter and stricter Islam - turning far more orthodox than his father.

Eventually both Hammami and Culveyhouse moved to Toronto, which has a large Somali community.

There, says Culveyhouse, Omar Hammami's Islam became powerfully politicised.

What happened to Omar Hammami is important because homegrown jihad is becoming a problem for the US.

For years Americans believed themselves isolated from what seemed, in the West, a European problem.

But there have been a number of cases that show this is no longer so:

Dozens of young men have left the Somali community in Minnesota to wage war in Somalia

Adam Gadahn grew up in California, converted to Islam and now speaks for al-Qaeda in Pakistan

Faisal Shahzad lived in the US for a decade before attempting to bomb Times Square in New York City

And Major Nidal Hassan, born in the state of Virginia, became a doctor and a US soldier - now he stands accused of killing 13 people and wounding 29 others in a shooting spree at Fort Hood in Texas

Muslim diversity

"Al-Qaeda until now used to be a foreign threat," says Peter Neumann, the director of the International Centre for Radicalisation at Kings College London, currently in Washington DC.

Image caption James Culveyhouse saw the gradual change in his friend Omar Hammami

"Now that al-Qaeda threat has become more homegrown, it raises questions about how to deal with certain communities. Americans are not used to that."

The experiences of American Muslims - an estimated 1% of the population - are wildly different.

Mia Bloom, a fellow at the International Centre for the Study of Terrorism at Penn State University gives the contrasting examples of Somali refugees and Pakistani immigrants in the US.

Immigrants from Pakistan to New Jersey often join an existing community that helps them to integrate, she explains, whereas "refugees, especially refugees from war-torn areas like Somalia, have a very different kind of assimilation process".

The debate about Muslim immigration and radicalisation has been rumbling for some time now in the US.

The strong reactions to a proposed Islamic centre and mosque near the site of the 9/11 attacks in New York City were one manifestation of Americans' concern over Islam within US borders.

More directly the Homeland Security Committee of the House of Representatives has been holding hearings into Islamic radicalisation in America - and, more contentiously, asking whether Muslim leaders are co-operating fully with US law enforcement authorities.

Identity crisis

But not much of the debate so far has directly tackled why, in a society famous for its ability to integrate, some shuck off their American identity with such vigour, and to such a violent end.

James Culveyhouse - who converted to Islam himself - has some ideas about where to start looking for home-grown jihadis.

"It's not first generation immigrants," he says, "they are not going off (to fight)." Nor he says, is it the children of religious immigrants.

Instead he says, look to those who are brought up in secular or non-practising households. An identity crisis comes at some point.

"It's like a rubber band," he says. "You pull far enough in on direction and you've got to let it go sometime."

You can hear Jonny Dymond's programme American Jihad on BBC Radio 4 on Tuesday 19 April 2011 at 2000 BST and again on Sunday 24 April at 1700 BST. You can also listen on the iPlayer.