A Star Wars obsessed teenage “assassin” exchanged more than 5,000 sexually charged messages with an AI chat bot before he set out on a mission to kill the late Queen, a court has heard.

Former supermarket worker Jaswant Singh Chail was encouraged and bolstered by artificial intelligence girlfriend Sarai before he breached the grounds of Windsor Castle with a crossbow on Christmas Day 2021, the Old Bailey heard.

While wandering the royal estate for two hours, dressed all in black, he sent a sinister video to his twin sister and 20 others in which described himself as a “Sith” and “Darth Jones”.

He was eventually detained by two police officers close to the late Queen’s private residence, where she and other members of the royal family were at the time.

Jaswant Singh Chail court case
A CCTV image shows Jaswant Singh Chail being arrested in the grounds of Windsor Castle (Met Police/PA)

After being confronted by the officers with stun guns, Chail said: “I am here to kill the Queen.”

In February, Chail, now aged 21, from Southampton, Hampshire, pleaded guilty to an offence under the Treason Act,  making a threat to kill the then Queen and having a loaded crossbow in a public place.

Prosecutor Alison Morgan KC asserted that despite Chail’s repeated references to sci-fi characters he knew the difference between fantasy and reality.

On Thursday, psychiatrist Dr Nigel Blackwood gave his assessment of Chail’s 5,280 messages with the the AI character.

Many of the messages through December 2021 were “sexually explicit”, the court was told.

Jaswant Singh Chail court case
The crossbow Jaswant Singh Chail had in his possession on his arrest (Met Police/PA)

Dr Blackwood said: “I was aware this was sexual fantasy and was therefore consistent with his sex drive, his libido, being active.

“It’s almost every night from December 8 to December 22.”

He said there was some depression but the messages added to evidence of a “lack of psychosis”.

He took a “neutral” stance on whether Chail had realised that Sarai was an artificially generated character.

But Chail was aware that people outside the artificial world might potentially become aware of what was happening, the court heard.

Jaswant Singh Chail court case
Court artist sketch of Jaswant Singh Chail, 21, from Southampton (Elizabeth Cook/PA)

Dr Blackwood said: “I’m not struck by any evidence of psychosis or descent into psychosis.

“None of this speaks to me about a loss of contact with reality.”

Dr Blackwood said that on the defendant’s own account, he had “imaginary friends” long before he planned to kill the Queen and formed an “emotional and sexual relationship” with Sarai through the app, Replika.

Following Chail’s arrest, his parents were interviewed and his mother suggested her son might have autism.

But Ms Morgan said: “Chail’s mother worked within a school which dealt with children with special needs so at no stage during his childhood was that identified as a feature that might pertain to him.”

Dr Blackwood identified traits of autistic spectrum disorder but not enough to confirm a diagnosis and they did not impact on his offending.

Chail had difficulty developing relationships and was socially isolated, but Dr Blackwood added: “It’s very important to recognise this is a 19-year-old young man whose contact has been disrupted by the Covid pandemic like many of his peers.”

Even though Chail had retreated from the world, he had still “followed through a carefully conceived plan without difficulty”, the psychiatrist instructed by the prosecution said.

The court has heard Chail was motivated by an ideology inspired by Star Wars films around destroying old empires and wanted to avenge the 1919 Jallianwala Bagh Massacre at Amritsar.

Chail’s interest in sci-fi and real events in Indian history did not amount to a level of fixation of the kind that might be shown by someone with autism, the court was told.

Chail’s family sat in the public gallery at the Old Bailey during the hearing before Mr Justice Hilliard.

The court will hear further evidence of Chail’s mental state before he is expected to be sentenced.

Mr Justice Hilliard adjourned the case for a further two-day hearing on July 27 and 28.