Media playback is unsupported on your device Media caption The agent said MI5 was "totally understaffed" to meet the challenge after 9/11

A former MI5 spy has broken cover to give the BBC an unprecedented account of his life in service - and describe his anger at the way he was treated.

The agent, codenamed Robert Acott, said he spied for 18 years, mostly following Islamic and Irish terrorist suspects.

He told Newsnight MI5 had pushed him out after he suffered symptoms of stress, later diagnosed as PTSD.

MI5 would not comment on the claims - but security sources said they felt his was only one side of the story.

In an interview with Newsnight, Acott says:

MI5 was completely unprepared for the Islamist terror threat and was so short-staffed during one major plot that it had to rely on British Transport Police to follow terrorist suspects

The agency had so few non-white officers that one team leader considered "blacking-up" agents - this was tried on a training exercise

The agency had to undertake some surveillance operations because of suspicions of corruption and leaks within the police

He challenged senior managers when his team was tasked with looking at a suspected paedophile. Acott considered this beyond the agency's remit. The operation lasted several weeks, but he says he saw no evidence of child abuse

Acott, 46, was dismissed five years ago for misconduct after leaving an unmarked MI5 training manual in his garden shed. It was found by a member of the public and handed to police.

MI5 was my life. I would have done... anything for them

At the time he was sacked, Acott was suffering from panic attacks - and he has since been diagnosed as suffering from Complex Post Traumatic Stress Disorder, brought on by the pressure of his career in the service.

Acott claims MI5 took an opportunity to get rid of him. "MI5 was my life," he says. "I would have done - within reason - anything for them."

Though former director-generals of MI5 such as Dame Stella Rimington and Baroness Eliza Manningham-Buller have written about their time in the secret service, Acott's is the first account of life as a 'foot-soldier' in the dangerous and secretive world of counter-espionage.

Acott told Newsnight he was immensely proud to have been an MI5 surveillance officer - he was recruited from the Royal Navy by a senior officer.

He says he put himself in numerous dangerous situations because he believed in the work he was doing.

But he admitted the pressure began to get to him after 9/11 when MI5 found itself completely unprepared for the Islamic terrorist threat. There was only one Muslim surveillance officer he was aware of in the whole of the surveillance unit.

"(MI5) was totally understaffed. We weren't used to dealing with the way they acted. The good thing about following Irish targets is the Active Service Units would generally meet in pubs you could go into.

"The Islamists would meet round each other's houses or in mosques which you can't get away with going into. Also, they were living in mostly ethnic areas and often you would find the only white people on the street were surveillance officers."

MI5 was blindsided by the July 7 attacks in 2005 and was stretched to breaking point when it helped foil the plot to detonate explosives on transatlantic airliners a year later.

"It was horrendous. We had around eight targets mostly based in Walthamstow, a couple in High Wycombe. It was 24 hours a day. It went on for quite some time," says Acott.

"With all of Special Branch, with all of MI5, there was just not enough people. CID became involved, British Transport police became involved. That's how desperate we'd become.

"If that airline job had gone as planned it would have eclipsed 9/11. It would have been horrendous."

Find out more The full report with former MI5 agent Robert Acott was on Newsnight, on BBC Two at 10:30pm on Wednesday 15 July Watch on BBC iPlayer

Acott was in a team following the ringleader of the group, whose codename was Lion Roar. "He was the leader, he was the boss. He was in two minds about whether to martyr his wife and child as well as himself. Just before he was arrested, he took his wife and child with him to Mothercare. It seemed unbelievable to me that he could do that at the same time as he was thinking of killing so many people."

"They were making martyrdom videos. We had cameras hidden in the flat so we could see them videoing themselves."

Acott said following new suspects on the London underground became particularly stressful.

"The jobs I was really unhappy with was what they would call 'the first look up'. If they were a terrorist you had no idea at what stage they were at. I became particularly nervous of travelling on tubes with them."

"On one occasion this chap had shaved his head, which is a ritual they go through. He was on the tube and was stood by the doors in the middle. I was at the end of the tube keeping an eye on him. I had been separated from my team.

"My body comms didn't work very well underground. I was on my own. I looked around. People were on phones, doing crosswords, a woman with a toddler trying to keep it under control. I started having a panic attack."

Media playback is unsupported on your device Media caption The spy describes his first panic attack in the job

Acott says he travelled all over the world for MI5, following suspects out of the UK to Europe and the Middle East on a passport with a false identity.

He also went to Ireland to provide covert help to MI5 handlers who had meetings with IRA double agents.

Acott said the trips were undeclared to the Irish government and the surveillance teams would have been stranded had they been caught by republicans - or the Garda.

The surveillance on the suspected paedophile - codenamed Operation Saturday - caused him concern, he says, because he couldn't understand why MI5 was doing it.

"It involved extremely powerful, wealthy people. It was a very need to know job... We were given the scantest of briefings on it. All of a sudden the job stopped. I did actually question why were we doing paedophiles - it wasn't in our remit.

"The trouble with the police is they move from job to job. Special Branch only do it for three or four years. Then they go onto CID or some other job. There was a strong suspicion of corruption within the police, whereas MI5 was more highly trusted."

The operation ended after a few weeks - Acott says the target was using drugs and prostitutes, but he saw no signs of child abuse.

Acott says his health began to deteriorate in 2006. He began to have nightmares and panic attacks and he was drinking to help cope with the pressure.

"I know I was in a mess at the time. But the service didn't want to deal with that. Once they realised I had health problems, I think they just wanted rid of me.

Image copyright Robert Acott Image caption Robert Acott has been diagnosed as having PTSD

"They went through the motions. I was definitely being bullied by my team leader and my junior team leader... They sent me to see a doctor. However the doctor wasn't there to help me as far as I could see. He was there to diagnose me as an alcoholic."

Acott was dismissed for gross misconduct over the file he had left in his garden shed. He told an MI5 tribunal the document was so dull he didn't believe it had any security status, but he was sacked.

The dismissal, he says, accelerated his health problems - he tried to commit suicide on at least three occasions. His parents, who have also spoken to the BBC, said they were convinced their son was suffering from PTSD, but a psychologist used by the service disagreed.

In a letter to his parents, MI5 said: "It is important to reiterate that this Department is not responsible for his health problems, nor do his problems stem from his time working here."

However, four doctors have now diagnosed him as suffering from PTSD - including clinicians from the military veterans' charity, Combat Stress.

Acott recently attended one of the charity's residential courses.

He told Newsnight he wants MI5 to admit it made a mistake when he was sacked. He also believes he is entitled to a medical pension.

Security sources insisted that MI5 has professional teams that support the physical and mental wellbeing of staff because of "the very particular nature of the work".

Sources said staff do come forward and that support teams are proactive "during difficult periods such as at a time of particular operational intensity or following the death of a colleague".

The full report with former MI5 agent Robert Acott was on Newsnight, on BBC Two at 10:30pm on Wednesday 15 July. You can also watch on iPlayer.