A jury has retired to consider its verdict in the trial of a south London teenager accused of hatching a plot to behead a British soldier inspired by the Woolwich murder of Fusilier Lee Rigby.

Brusthom Ziamani, 19, was arrested in an east London street last August carrying a black flag, a 12in (30cm) knife and a hammer in a rucksack, having earlier researched the location of army cadet bases in the south east of the capital.

His Old Bailey trial heard that he "reverted" to Islam early last year and was arrested after he showed his ex-girlfriend weapons, described Fusilier Rigby's killer Michael Adebolajo as a "legend", and told her he would "kill soldiers".

After being kicked out of his home when his Jehovah's Witness parents discovered his new-found religion, he turned to extremists in the Muslim group al-Muhajiroun - or ALM - who gave him money, clothes and a place to stay.

He attended their talks in the basement of a Halal sweet shop in Whitechapel and bought a black flag to take on their demonstrations, saying "I'm going to rock it everywhere I go in the Kaffirs' face".

After just months of learning about the Muslim religion, he posted comments on Facebook that he was "willing to die in the cause of Allah" and saying: "Sharia law on its way on our streets. We will implement it, it's part of our religion."

At the time he was first arrested last June on an unrelated matter, police found a ripped-up letter in his jeans pocket in which he wrote about mounting an attack on a British soldier and expressed the desire to die a martyr.

But Ziamani, of Camberwell, denied a charge of preparing an act of terrorism on or before August 20 last year.

On the letter, he said: "I was ranting and raging about the situation in Muslim countries which was described in these talks. I did not believe it at all."

And he explained his Facebook postings as an attempt to "fit in" with the ALM group because they were giving him a place to stay.

Defending, his lawyer Naeem Mian told the jury that Ziamani could not be convicted for having "offensive" or "repulsive" views and there was no evidence he had actually carried out any reconnaissance for a terror attack.

He said: "We all have the right to have an interest in gore and grisly stuff. We have the right to have undoubtedly repulsive views, some of which he has expressed. He is not on trial for his views."

The 11-strong jury of seven women and four men retired to consider its verdict just before 11am on Wednesday.