Jaswant Singh Chail, 21, who was detained in the castle grounds on Christmas Day 2021 while the Queen was in residence, has admitted treason.
Ms Chbat said: “He has expressed distress and sadness about the impact his actions had on the royal family, particularly while Her Majesty was in her latter years.”
Referring to the letter, she said: “He has apologised to the royal family and His Majesty King Charles.
“He is embarrassed and ashamed he brought such horrific and worrying times to their front door.”
Ms Chbat added: “He has expressed relief no-one was actually hurt. It is important to him there was a surrender.”
Before his mental health declined, Chail was a kind, gentle and sometimes funny person, his family and friends said.
Ms Chbat said: “He was at the time of this offending 19 years old. Lockdown gripped the nation in March 2020. He was only 18 years old when we went into the first lockdown.”
Chail’s “strong family unit” includes his father, a software consultant working in aerospace, his mother, a special needs teacher, and his twin sister, a university student.
Ms Chbat said: “The events of December have utterly shocked and devastated this family unit and the defendant has sincere regret for how this has impacted on his family.
“And that deep regret will be with him for the rest of his life because of the severity of the offending that took place.”
Chail was encouraged to kill the Queen by an artificial intelligence girlfriend called Sarai, the court heard.
On the day he got into the castle grounds, Star Wars fanatic Chail sent a homemade video to family and friends on WhatsApp in which he apologised for what he was about to do and called himself “Darth Chailus”.
Chail wore dark clothes and a metal mask as he adopted the persona of a Star Wars villain for the video.
In the clip, the defendant, who has Sikh Indian heritage, said he was seeking revenge for the Amritsar massacre in 1919, when British troops opened fire on thousands of Indians and left up to 1,500 dead.
Chail embarked on his murderous mission after his bids to join the armed forces – to get close to the royal family – failed in late 2021, the court was told.
During Friday’s hearing, prosecutor Alison Morgan KC said Chail’s crimes were so serious they should attract the highest possible sentence.
She said: “This is not simply somebody carrying a crossbow – it was loaded and ready to be fired.”
The maximum sentence for treason is seven years in prison.
Had Chail raised his weapon at his target, he could have been charged with the more serious offence of high treason, which carries a life sentence, she said.
Ms Morgan added: “I can think of three offences carrying a sentence of life imprisonment which Mr Chail could have faced, particularly if he had lifted that crossbow up in the castle.
“That gives an idea of the seriousness.”
Mr Justice Hilliard said: “It might be said that if it’s a prime minister, any other significant figure or politician, it is top of the range.”
Chail, who has also admitted making a threat to kill the Queen and having a loaded crossbow, appeared in court by video link from high-security psychiatric hospital Broadmoor.
The hearing follows seven days of evidence from three psychiatrists about Chail’s mental state as Mr Justice Hilliard considers whether he should be jailed, detained under the Mental Health Act or face a “hybrid” order.
His treating psychiatrist Dr Christian Brown, who recommended a hospital order, suggested Chail will need around 18 months of one-to-one therapy.
However, Professor Nigel Blackwood, for the prosecution, said the attack was carefully planned and Chail was well aware it was wrong.
Mr Justice Hilliard will sentence Chail at the Old Bailey on October 5.