A man who had previously been convicted of murder was sentenced to four months in prison on Friday after he pleaded guilty to trespassing in the grounds of Buckingham Palace, Queen Elizabeth II's official London residence.
Westminster Magistrates' Court, in central London, convicted Dennis Hennessy, 41, of "trespass on a protected site" and criminal damage.
He had been released on licence after serving a prison sentence for murdering a homeless man in 1992, the court heard.
The unarmed Hennessey was arrested on Wednesday night after spending about 10 minutes inside the palace grounds, the Metropolitan Police said in a statement.
The queen was at the palace at the time of the intrusion, sources said on condition of anonymity.
"He was located in the grounds by officers and arrested without incident; our security measures worked effectively and ensured the safety of those within the Palace," said Commander Adrian Usher, head of the force's royal protection unit.
The incident follows several previous reports of intrusions at thepalace, including one in November by two fathers' rights protesterswho used a ladder to climb onto a roof.
Another man was arrested in a public room inside the palace late one evening in 2013 after he had scaled a fence.
In the most serious incident, in 1982, Michael Fagan entered thequeen's bedroom and spoke to her for 10 minutes before she was ableto raise the alarm.