A convicted murderer who scaled the perimeter wall of Buckingham Palace before "admiring" the gardens for 10 minutes has been jailed for four months.
Denis Hennessy cut his right hand on barbed wire as he climbed over the top of the wall, which is between 2.5m-3m high, and set the alarm off.
He then walked around the gardens for about 10 minutes towards the palace, where the Queen was in residence with the Duke of Edinburgh and the Duke of York, before being arrested by armed police.
As he was detained, he asked "Is Ma'am in?" repeatedly, prosecutor Tom Nicholson told Westminster Magistrates' Court on Friday.
Hennessy, 41, pleaded guilty to one count of trespass on a protected site and one count of criminal damage.
Nicholson said Hennessy had damaged wiring for the alarm system, to the value of up to STG2000 ($A4000), as he scaled the wall at around 8.37pm on Wednesday.
He was arrested at around 8.50pm, about 50m from the palace, after triggering a "full-scale alert" involving a sweep of the grounds with dogs and a helicopter.
Nicholson said: "At the point when the defendant entered the site, Her Majesty the Queen was in residence along with the Duke of Edinburgh and the Duke of York.
"It caused them significant inconvenience."
Sikander Choudry, defending, said the unemployed stonemason had been drinking before the incident.
The court also heard he was on licence for life after being convicted of the murder of a homeless man in 1992.
Nicholson said: "At the age of 17 on Friday, June 19 1992 he had been accosted by someone homeless in the street who had asked him for money and knocked food out of his hand.
"Hennessy became angry and attacked him with an iron bar, fracturing his skull into small pieces." Hennessy, who had been sniffing butane gas before the attack, then jumped on the victim's head, killing him.
He was convicted in 1993 at the Old Bailey and released from prison in 2002, before the probation service stopped monitoring him in 2013.
Hennessy also had a conviction for shoplifting in 2016.
Chief Magistrate, senior district judge Howard Riddle, sentenced him to four months for trespassing and two months, to run concurrently, for damaging the wires of the alarm system.
His intrusion led to "serious consequences" and the alarm would need to be "refixed", Judge Riddle said.
He added: "In 1993 at the Old Bailey, he was convicted of murder, a particularly brutal murder as it happens - that's an aggravating factor."
Hennessy's explanation for going into the gardens was "not credible", the judge said.
He said: "The fact of the matter is, we simply don't know why he was there and that makes it a matter of considerable concern."