Prince Harry served as an Apache helicopter pilot in Afghanistan. Photo: AP
A Muslim convert planned to disarm a royal bodyguard and use the gun to kill Prince Harry in an attack he had named Operation Regal.
Ashraf Islam, 31, formerly known as Mark Townley, confessed to police that he had ''advanced plans'' to kill the Prince the day after he was arrested in May.
Belfast-born Islam was held the day after Drummer Lee Rigby was murdered in Woolwich, and said the fourth in line to the throne ''had blood on his hands'' after two tours of duty in Afghanistan.
He spent 10 days in Thailand building up his fitness, carrying out research on the internet and refining his plans, before flying to London to carry out the attack.
But he began to feel ''scared and nervous'' and walked into Hounslow police station in west London, where he confessed to the plot.
He pleaded guilty to one count of making a threat to kill when he appeared before magistrates on May 25, two days after giving himself up.
On Friday, at a sentencing hearing at Isleworth Crown Court, Lynne Townley, prosecuting, said Islam told an officer he had watched soldiers on Horse Guards Parade ''and planned to disarm an officer whilst disguised as a tourist rather than bringing a gun into London''.
She added: ''He used his time in Thailand to get his fitness to a higher level. He planned to send a telephone warning to create a diversion.''
A document found on Islam's computer said: ''Aim for target. No civilians to be injured. Dress code is the biker look. Use low calibre pistol at close range. Not to be viewed as Islamist extremist.''
After analysing his laptop police found a number of internet searches showing Islam had been researching Prince Harry's protection team, where he lived, his royal engagements and his whereabouts.
A video found on the computer showed him making threats to kill the Prince to camera while he was in Malaysia.
The court was told that Islam became separated from his wife and child in Belfast after making ''several reckless financial decisions'', and changed his name by deed poll in 2010 after converting to Islam.
He later moved to Dublin because there was a bigger Muslim community there before travelling to Cairo to learn more about the religion.
Miss Townley said that after landing at Heathrow on a flight from Thailand, Islam checked into a Travelodge hotel and at 11am the following morning, May 23, went to Hounslow police station and asked to speak to an officer.
He told duty officer Pc Boyne that he wanted to talk about a murder and asked to speak in private. Islam was led to a room, sat down and appeared to be calm, the court heard.
Miss Townley said: ''He told the officer he had come to the station because he wanted to admit to a serious incident which he would commit the next day.
''He said he was being monitored by UK security. He was asked for further details of what these plans were and he said it was the murder of a high profile person.
''The Pc called a sergeant and counter terrorism officers. Islam was asked which particular person he intended to kill. It was at this point he said Prince Harry. He said he intended to kill Prince Harry tomorrow.''
Islam told the officers he did not agree with the murder of Drummer Rigby, who was knifed in the street by two Islamic extremists, because the soldier was ''a soft target''.
He said he believed hurting people was wrong but ''Prince Harry had chosen his path and had blood on his hands for power and profit''.
Sentencing was adjourned until November 1 for an assessment of Islam's mental health to be carried out.