Brustholm Ziamani, 19, was arrested on a street in east London in August carrying a 12-inch knife and a hammer in a rucksack, having earlier researched the location of army cadet bases in south-east London, the Old Bailey heard.
Ziamani had “reverted” to Islam early in 2014 and his August arrest came after he showed his former girlfriend the weapons, described Lee Rigby’s killer Michael Adebolajo as a “legend” and told her he would “kill soldiers”, prosecutor Annabel Darlow said.
The jury heard he also put posts on Facebook under the name Mujahid Karim supporting Sharia law and stating he was “willing to die in the cause of Allah”.
Ms Darlow said: “He didn’t say anything when he was arrested on that particular occasion but he was remanded and told a security officer that he had been on his way to kill a British soldier at an army barracks when he had been arrested. He said he was going to behead the soldier and hold that soldier’s head up in the air so that a friend could take a photograph with the severed head of the soldier.
“You may think that his aim was to emulate the dubious feats of his hero Michael Adebolajo, who had murdered a British soldier close to the Woolwich barracks where he worked.”
Ziamani, of Camberwell, London, denies a charge of preparing an act of terrorism on or before 20 August last year.
Ziamani had previously been arrested in June 2014, the court heard.
The court heard that on 20 June, he had entered “Camberwell army cadets” into Google and looked at the website of the London Irish Rifles Association, and for cadets in Lewisham, looking at details of the Army Cadet Force in Blackheath.
Ms Darlow added: “These were all military targets which would reflect the defendant’s stated intention to wage war on the British Government and to further his ambition of carrying out attacks like those on Lee Rigby in Woolwich.”
After his June arrest, police found a letter in his jeans to his “beloved parents” saying he was a “changed person”.
He wrote of being martyred and going to paradise and referenced people being raped, tortured and killed in Iraq and Syria, saying that he had a “duty” to help them.
He wrote: “Because I have no means ov gettin there I will wage war against the british government on this soil the british government will have a taste of there own medicine they will be humiliated this is ISIB Islamic State of Ireland and Britain [all sic].”
He added: “Now we will take a thousand ov yours then ten thousand and send you all to the hell-fire you want war you got it British soldiers heads will be removed and burned u cannot defeat the Muslims we love to die the way you love to live my fellow muslim brothers these people want war lets kill them slaughter them and implement sharia in our lands and UK [all sic].”
Ziamani went on: “Lee Rigby is burnin in hell im dying good for him this is what you get for voting Cameron and democracy.”
He said he looked up to radical preachers including Abu Hamza, but denied he planned an attack. He was later released on bail and spoken to in July by anti-radicalisation officers.
The court heard he was unresponsive and said he “did not need help with his religion” and had left the home of his Christian family. Ziamani continued to post extremist material on Facebook.
The trial continues.