A 14-year-old British boy came within days of successfully plotting an Anzac Day terror "massacre" in Australia after he was radicalised by online Islamic State propaganda, a court has heard.
The youngster, from Blackburn, Lancashire, found an online jihadist community through his first smartphone which "filled a void" caused by problems he was having at school and at home as well as a degenerative eye condition.
Within two weeks of setting up a Twitter account he had 24,000 followers as he constructed a fantasy image of himself and "quickly became a celebrity" within the jihadi Twitter community.
Thought to be the UK's youngest terrorist, he went on to plot an attack on an Anzac Day memorial parade in Melbourne this April from the bedroom of his parents' suburban home.
Over the course of nine days in March this year he took on the role of "organiser and adviser" to an alleged Australian jihadist named Sevdet Besim to murder police officers by beheading, Manchester Crown Court was told.
His contact with Besim - in which more than 3,000 encrypted messages were exchanged - was instigated by a well-known Isis recruiter and propagandist named Abu Khaled al-Cambodi, himself an Australian, who has promoted the idea of terrorist attacks in his homeland, said the Crown.
Prosecutor Paul Greaney QC told the youth's sentencing hearing: "There is no doubt that there was a determination on the part of the defendant and Sevdet Besim that the plot should be carried through and the contact between the two included frequent references to the production of a martyrdom video by Besim for al-Cambodi which, no doubt, al-Cambodi intended to use for propaganda purposes.
"In the event, fortunately, the authorities here and in Australia intervened and a plot that would in all probability have resulted in a number of deaths was thwarted."
Within hours of the pair first making contact not only had the plotters determined that the attack was to take place in Australia but also the idea of an attack upon police officers was taking hold, said Mr Greaney
In the early hours of March 18, Besim suggested an attack on Anzac Day, the court heard.
The defendant messaged, "Sounds good", and Besim replied: "Make sure the dogs remember this as well as there fallen 'heroes'."
Mr Greaney said: "Shortly after this exchange about Anzac Day, (the defendant) suggested that Besim should "break into someone's house and get your first taste of beheading".
On March 19 the defendant said to Besim that he was going to present him three options - a gun attack on the police, a car attack on the police or a knife attack on the police.
Besim expressed a wish for a combination of a car and knife attack.
Messages discussing the weapons to be used followed and in the early hours of March 23 Besim said he was travelling with a machete, knife, Taser and a Shahada (martyrdom) flag in his car.
When Besim sent him a photograph of a knife, the defendant replied: "Handle is perfect for tearing through throat."
On March 24 Besim messaged the defendant: "So far the plan is to run a cop over on the anzac parade & then continue to kill a cop then take ghanimah and run to shahadah?"
The defendant responded: "ill give orders soon but its looking along that line."
The following day the defendant told Besim to make sure he was shot during the attack.
Besim replied: "I feel lik a young kid with a ticket to disney world cant wait ahahah. Yeh I wanna make sure I get shot to. Not b4 I take out at least 1."
Hours later the defendant was under arrest and his phone was in the possession of the police after concerns had been raised of his extremist behaviour at school where classmates had nicknamed him "The Terrorist".
On April 15 Besim conducted further internet research on the Anzac Day parade, including in relation to a particular road.
Three days later - a week before the parade - the police acted and Besim was arrested where he was found to be in possession of a knife, the court heard
Knives and a large Shahada flag were recovered from his home, with a phone that contained a martyrdom message.
Mr Greaney said: "The position of the prosecution is that a major terrorist plot in its late stages, orchestrated from the North of England but to be carried out in Melbourne, had been thwarted."
The court was told the defendant had subsequently told a psychiatrist in custody that he was convinced that if the police had not disrupted his activities "a massacre would have occurred" and in this way he thought he "would become notorious".
James Pickup QC, representing the defendant, questioned the prosecution argument that his client was the driving influence behind Besim's plans.
He explained how the Australian was already radicalised and fully aware of jihadist ideology.
The barrister said: "It is apparent that (the defendant) provided no more than emotional support, guidance to a limited degree, to someone who was well versed in the preparation of terrorist attacks."
The smartly dressed and bespectacled teenager, now aged 15, sat watching the proceedings from within the courtroom, flanked by his parents.
His mother began crying when the court discussed possible sentencing terms.
The youth, who cannot be named for legal reasons, pleaded guilty in July to inciting terrorism overseas.
Mr Justice Saunders will sentence him on Friday.
Mr Pickup said the defendant had made considerable progress at the specialist unit where he is being held.
He told the judge: "He accepts his crimes were barbaric, immoral and wholly wrong."
The barrister said that the "void that was filled by the extremist propaganda of Isis no longer exists".
He said this is now filled by positive influences, including the support of his family.
Mr Pickup said the boy was now studying for GCSEs and taking part in group activities , like football, which he never did before.
He said there was a "clear contrast between his 'then' behaviour and his 'now' behaviour".
Mr Pickup said: "If he were to be released today, then he may still be regarded as a risk. We would suggest that on release today his risk would not be significant. It wouldn't make him dangerous."
Besim is awaiting trial in Australia next year.
Sentencing will take on Friday from 10.30am.
Mr Justice Saunders said he would rule beforehand on an application from members of the press to lift reporting restrictions on identifying the defendant.