The man was spotted on Christmas Day 2021 wearing black clothes and a metal mask within the grounds of Windsor Castle, seen here in February 2022.
London CNN  — 

A British man who broke into Windsor Castle with a loaded crossbow and planned to assassinate Queen Elizabeth II has been handed a nine-year jail sentence.

Jaswant Singh Chail, 21, was arrested on Christmas Day 2021 within the grounds of the royal residence, where the late monarch was staying during the pandemic.

Chail was thought to have scaled the castle’s perimeter with a nylon rope ladder before he was detained. Wearing black clothes and a sinister metal mask, he told a police protection officer, “I am here to kill the Queen,” before being arrested.

In February, Chail pleaded guilty to three charges, including treason and possession of an offensive weapon, at a hearing at London’s Old Bailey court.

This undated photo, released by the Crown Prosecution Service (CPS) on February 3, shows the crossbow that Chail was carrying when he was arrested.

Sentencing judge Justice Hilliard jailed him for nine years with a further five years on extended licence, the PA Media news agency reported Thursday.

“The defendant harbored homicidal thoughts which he acted on before he became psychotic,” the judge said. “His intention was not just to harm or alarm the sovereign – but to kill her.”

Chail was sentenced under a “hybrid order” under the Mental Health Act, meaning he will serve his term at Broadmoor high-security psychiatric hospital until he is well enough to be transferred to prison, according to PA Media.

The court heard that Chail was a “Star Wars” fan who described himself as a “Sith” in a video that he sent to about 20 people after breaching the castle grounds, and had been pushed to break into the castle by his AI chatbot “girlfriend,” the UK news agency reported.

The mask which Chail was wearing when he was caught in the grounds of Windsor Castle, in a photo released by the CPS.

The Old Bailey was also told that Chail wrote in a journal he tried to email his sister that if the sovereign was “unobtainable” he would “have to go for” the prince, an apparent reference to then-Prince Charles, as “he seems to be just as suitable in many ways.”

British media reported that Chail was the first person in the UK to be convicted of treason in over 40 years.

According to PA Media, Chail apologized to the royal family in a letter to the court, in which he expressed his “distress and sadness.”

“He is embarrassed and ashamed he brought such horrific and worrying times to their front door,” his barrister Nadia Chbat said. “He has expressed relief no one was actually hurt.”

Sign up for CNN’s Royal News, a weekly dispatch bringing you the inside track on the royal family, what they are up to in public and what’s happening behind palace walls.