Image caption The court heard Brusthom Ziamani had posted extremist material on Facebook saying he was "willing to die in the cause of Allah"

A teenage Muslim convert accused of planning to behead a British soldier claimed he knew one of Fusilier Lee Rigby's murderers, a court has heard.

Brusthom Ziamani told a prison officer he had delivered Islamic leaflets with the Woolwich soldier killer Michael Adebolajo, the Old Bailey heard.

The 19-year-old also wanted to "harm" Prime Minister David Cameron if he had the chance, it is alleged.

Mr Ziamani, of Camberwell, London, denies preparing an act of terrorism.

Police arrested Mr Ziamani in east London in August last year. At the time he was carrying a rucksack containing a 12in knife, a hammer and an Islamic flag, the court has heard.

Image copyright Metropolitan Police Image caption This Islamic Shahada flag was among items in Brusthom Ziamani's rucksack on his arrest, the court heard

Image copyright Metropolitan Police Image caption The 19-year-old was also carrying this hammer

Image copyright Metropolitan Police Image caption Mr Ziamani was also carrying a 12in knife when he was arrested, the Old Bailey heard

Paul Morris, a prison officer at HMP Wandsworth, told the court that during a "welfare" chat while Mr Ziamani was on remand, the teenager "said he knew Michael Adebolajo".

"He said he loved him and he said he used to hand out leaflets in Greenwich with him as well. He said he had never met [the other Woolwich killer] Michael Adebowale," he told the court.

He added: "What concerned me was that first of all I was not sure if he was making some of it up.

"When he said he didn't know Adebowale I felt he was telling the truth - he was not trying to tell me he knew all these people. So for me I was believing what he was saying."

He said he had spoken one-to-one with Mr Ziamani in his cell, before immediately going to make notes of what was said.

"He said that he had been arrested when he was on his way to an army barracks, he didn't say where.

"He said he was going to behead a British soldier and hold his head up in the air while a friend took a photo of him doing so."

'Willing martyr'

Naeem Mian, defending Mr Ziamani, said there was no dispute that the teenager had said he was on his way to behead a soldier.

But he suggested that it was said to the prison officer just in the context of explaining what the allegations against him were, rather than as a confession.

Mr Morris replied: "That [a confession] is how I perceived it at the time. When I first asked him why he was here he could have said there and then."

The court previously heard that Mr Ziamani idolised Adebolajo, telling an ex-girlfriend that he was a "legend".

Image copyright PA Image caption Fusilier Lee Rigby was murdered in Woolwich, south-east London, in May 2013

Counter-terror police had previously arrested Mr Ziamani in June last year over extremist posts he made online and had questioned him several times, the Old Bailey also heard.

In an exchange from one interview read to the jury, he was asked by officers to confirm what he had said in an earlier interview in which the tape recorder had broken.

"What would you do if you saw David Cameron and had an opportunity?" the officer asked.

"You said you would do him harm if he had no security around?"

Mr Ziamani replied: "Yes."

The interviews also discussed a letter written by Mr Ziamani addressed to his parents in which he talked about being martyred, the court heard.

Mr Ziamani is said to have converted to Islam in early 2014.

The jury heard he put posts on Facebook under the name Mujahid Karim, supporting Sharia law and stating he was "willing to die in the cause of Allah".

Mr Ziamani denies a charge of preparing an act of terrorism on or before 20 August last year.