A prosecutor says a British teen planned to behead a soldier after he was inspired by the Islamic extremists who murdered soldier Lee Rigby in 2013.

Prosecutor Annabel Darlow told the Old Bailey court Monday that Brusthom Ziamani told his girlfriend he planned to "kill soldiers" shortly before he was arrested in August carrying a 12-inch (30-centimeter) knife and a hammer in his backpack.

She said 19-year-old Ziamani idolized Michael Adebolajo, one of two men who hacked Rigby to death near his barracks.

Officials said Ziamani had used an alias in Facebook posts in which he called for the implementation of Sharia law in Britain and said he was willing to die for Islam.

Ziamani is charged with preparing an act of terrorism. He denies the charge.