An undercover officer was accused in court of planting a bomb in the car of a convicted terrorist to frame him and his "Three Musketeers" group for plotting an attack in Britain.

The officer, known as Vincent, was posing as the boss of Hero Couriers to infiltrate the alleged terror cell last summer, the Old Bailey has heard.

Four men were arrested on August 26 last year after a partially constructed pipe bomb, machete and imitation gun were discovered by security services in Naweed Ali's car.

Both 29-year-old Ali and his co-accused Khobaib Hussain, 25, had previous convictions for attending a terror training camp and had been given jobs by Vincent to travel around the country delivering parcels for £100 a day.

Ali's Seat Leon had been parked at the "covert" courier firm in Birmingham city centre while he went to Luton to deliver a parcel on his first day in the job.

Cross-examining, Stephen Kamlish QC suggested that Vincent had planted a bag of incriminating evidence in Ali's car before MI5 turned up to bug it.

He alleged that was his only window of opportunity as MI5 had already bugged Hussain's car after he had begun working for Hero Couriers the month before.

The officer, who gave evidence from behind a screen, described the suggestion as an "interesting work of fiction" but refused to go into detail about the security services' activities in the interests of "national security".

Mr Kamlish, for Ali, suggested Vincent - or MI5 - had searched Hussain's car the first time he came to work at Hero Couriers in July and found nothing.

The officer denied he had searched the car and said he could not say if the security services had or not.

Mr Kamlish went on: "From that date, there was a bug at least and probably a camera as well in his car that meant you could not enter it either to search or plant anything in it for the whole of July and August because there is a bug in it and people listening would have known."

Vincent replied: "I'm afraid I can't answer the first part of the question. The second part of that question you used the word plant. I would like to know on what basis I'm accused of planting that evidence."

The barrister said: "I will tell you over the next two days. I will ask you questions that will prove you planted this bag.

"You would be heard or seen planting evidence and the reason the bag was finally found allegedly on August 26 in somebody else's car was that MI5 were going to do the same thing that day and you had a window of one-and-a-half hours to do whatever it was you wanted to do before the bug was put in.

"You had until he left the car and MI5 came in to plant a bag of incriminating items in his car. This was your only opportunity - yes or no?"

The undercover officer said: "That's a interesting work of fiction. I'm afraid nothing you have just said to me makes any sense to me whatsoever. So no."

Mr Kamlish asked Vincent about the purpose of his undercover operation, which initially targeted Hussain before moving on to his next-door neighbour Ali.

He said: "Your operation in conjunction with the security services was to find evidence which would justify a prosecution against Khobaib Hussain and those of his associates who were believed to be extremist?"

Vincent replied: "That's correct."

The lawyer went on: "And your difficulty was that over the period of about a month when Khobaib Hussain was working for Hero Couriers, you found no such evidence, didn't you?

"How were you going to get evidence? All the evidence you were looking for was physical evidence."

The officer replied: "No it wasn't. I was there to provide counter-terrorism authorities and security services with opportunities to investigate those we believe were involved in terrorist activities and by employing them that may give a degree of control and give us the opportunity to gather evidence."

He said he took no part in any technical operations of the security services.

But Mr Kamlish asserted: "You watched security services plant a bug in Naweed Ali's car."

The witness denied it and the lawyer continued: "Did you see them place a fibre optic camera? A GPS tracker on the bumper?"

Vincent said he did not know what the technical operation on Ali's car involved, adding that he could not say any more in the "interests of national security".

Mr Kamlish asked whether anyone had searched Hussain's car during any of his nine visits to Hero Couriers in July and August last year.

Vincent said: "I'm afraid I cannot answer that question."

Ali and Hussain, both of Sparkhill in Birmingham, and Mohibur Rahman, 32, and Tahir Aziz, 38, of Stoke-on-Trent, deny preparing terrorist acts.

Later, Mr Kamlish told the witness: "You are hiding behind national security by using MI5 in this case."

Vincent denied it.

Mr Kamlish asked the officer why he had put his hand in the bag and pulled out what he thought was a "live bomb" after the secret services had been told to leave the depot.

Vincent said it was a "calculated risk", adding: "I'm not a bomb disposal expert but I know what a pipe bomb looks like.

"This was a fast-moving, difficult situation and difficult decisions had to be made and that difficult decision was made."

The barrister told Vincent he knew it was not a real bomb "because you put it there".

Asked if he planted the bomb, Vincent said: "I would never be involved in anything like that, have never, and will never."

Mr Kamlish said: "You knew this was not a bomb. Nobody in their right mind would pull it out of a bag, moving it to the ground sheet and stay with it."

Vincent said: "Why would I know it was not a viable device?"

Mr Kamlish replied: "You put it there."

The witness said: "I have been accused of a criminal offence. I want to know on what basis I'm being accused."

The lawyer also alleged that Vincent knew the gun in the bag was not a live pistol.

Mr Kamlish said Vincent had "faked up a find" by recording the contents of the bag after everyone else at the depot had pulled out.

Vincent said it was "nonsense".