Image caption The FBI have ensured Tamer El-Noury's true identity remains secret (file pic)

An active FBI undercover agent has revealed details of his work infiltrating Islamic extremist groups.

Tamer El-Noury - one of the agent's many false identities - talked to the BBC about his covert attempts to gain the trust of those planning attacks.

He was instrumental in foiling the plot to derail the New York City to Toronto train route four years ago.

He has published a book about his work, saying he wants Americans to understand his work as a Muslim operative.

"The fact is that these jihadists - these radicals that are popping up - are lost souls," he told the BBC in an interview. "They latch on to hatred, and an evil that seems to give them purpose."

"I am a Muslim and I am an American, and I am appalled at what these animals are doing to my country while desecrating my religion," he said.

'Chance encounter'

The son of Egyptian immigrants to the US, Mr El-Noury joined the police in New Jersey, where he worked to break up drug distribution networks.

Later, he was recruited by the FBI who realised they were desperately short of Arabic speakers.

Media playback is unsupported on your device Media caption "Tamer El-Noury" spoke to the BBC's Frank Gardner about his undercover life

One of his undercover operations involved a plan to kill as many people as possible by derailing the New York - Toronto rail route.

Tunisian migrant Chiheb Esseghaier, one of the key figures in the plot, was befriended by Mr El-Noury in a "chance encounter" arranged by the FBI.

He was eventually recruited by Esseghaier, becoming a part of the plot.

He posed as a wealthy American of Arabic origin who held a deep personal grudge - a persona, he said, he tried to keep close to the truth.

"None of my legends - none of my cover stories - have ever really drifted far from reality," he said.

"When you're travelling the world with an ideological extremist individual, and you're spending days - weeks - along with them, your true colours eventually come out when you get exhausted."

The long weeks spent with extremists, acting as confidant and close friend, "is the hardest part," he said.

Image copyright Penguin Image caption El-Noury's book has been carefully vetted by the FBI

"My job is to put my arms around a bad guy. And of course, all these atrocities that we are planning are sickening to me."

"The only way that I can be good at my job and have it believable is I try to latch on to whatever part is human... how well he speaks to his mother, how well he financially takes care of his siblings."

During a trip to New York Esseghaier began planning a future attack on Times Square in New York City on New Years' Eve, to take place after the train derailment, El-Noury told the CBS Sixty Minutes programme.

During the same trip, the pair visited the site of the Twin Towers, where Esseghaier said the US "needed another 9/11". El-Noury told CBS he "saw red" and almost blew his cover over the remark.

But none of the schemes ever came to fruition - both Esseghaier and Raed Jaser, a Canadian resident of Palestinian descent, were arrested in 2013 and sentenced to life in prison in 2015 on the back of El-Noury's investigation.

Mr El-Noury's story offers an extraordinary insight into the dark and dangerous world of going undercover as an agent, says the BBC's Security Correspondent Frank Gardener.

The FBI initially insisted on listening in on the telephone interview to ensure its active agent was protected, he said.

The nature of the agent's work is deceptive - but he said that any accusation of being a traitor was something he considered a badge of honour.

"These traitors, these radicals are the ones desecrating my religion. I am proud to be a patriot, i am proud to be an American Muslim fighting the war on terror."

His account of life undercover - American Radical - is published on 23 October by Penguin Random House.