A mental health patient who murdered a refugee and cut off his penis hours after being released from a psychiatric hospital has been jailed for at least 23 years.

Jeffrey Barry, 56, stabbed his neighbour, Kamil Ahmad, 49, to death at his flat in Wells Road in Bristol at about 2am on July 7 last year.

The murder took place hours after Barry, who has paranoid schizophrenia, was released from a psychiatric hospital.

Bristol Crown Court heard that psychiatrists had opposed Barry's release, but a mental health tribunal ruled that he should be discharged.

Barry told a community psychiatric nurse he was "criminally insane" in a phone call he made minutes before the fatal attack.

But police discovered a note in his room reading: "The fact is, I have acted out my entire psychiatric history. I'm very well. Sorry."

A jury unanimously convicted Barry, who is being held at Broadmoor Hospital, of murder following a two-week trial.

Jailing Barry for life, Mrs Justice May said: "In hindsight, the decision to discharge Mr Barry from hospital is nothing short of calamitous, given what happened hours later.

She told him: "Once inside Mr Ahmad's flat, you subjected him to a frenzied attack and the pathologist describes over 70 separate knife injuries.

"Mr Ahmad bled to death. After he died, you cut off his penis and then you went downstairs and phoned the police.

"On the jury's verdict, notwithstanding you were suffering from a chronic mental illness, you were not in such a grip of illness that you didn't know what you were doing."

Prosecutors had asserted that Mr Ahmad's murder was racially motivated and therefore should carry an increased sentence but the judge said Barry held a range of grievances against him.

"Mr Barry's thought system has been polluted and distorted by his mental illness over the years and the things he said cannot be judged by the standards of the sane general public," the judge added.

David Jeremy QC, defending, said Barry should never have been released by the mental health tribunal and that his client was a "victim" of a "flawed decision".

"In assessing his responsibility, the sentence should reflect that the responsibility for Mr Ahmad's death is shared by others," he said.

"The mental health tribunal discharged Mr Barry on the day he killed Mr Ahmad. They did so on a flawed process in which they were not provided with full information.

"The tribunal reached a conclusion that Dr (Dave) Barker, Dr (Roger) Thomas and Dr (John) Sandford said they didn't agree with.

"The defendant should not have been discharged to the address he shared with Mr Ahmad.

"It is too simple to pin responsibility to him in the sentence you will pass for the death of Mr Ahmad.

"Jeffrey Barry, as well as Mr Ahmad, is a victim of a flawed decision to discharge him from hospital on the day he went home to murder Mr Ahmad."

Mr Jeremy added that it would be "overly simplistic" to treat Mr Ahmad's death as a racially aggravated murder as he also thought he was a terrorist and a paedophile.

"Racial dislike was one hook against other hooks on which the defendant hung an irrational dislike of a man who had done him no harm," he added.

Barry was racist towards Mr Ahmad after he moved into the Wells Road flats, which are run by Milestones Trust for adults requiring support.

On May 24 last year, he told support workers he wanted to be notorious and murder a member of the public, adding: "Kamil would be top of my list."

He wrote a note saying he planned to kill people living in the house, including Mr Ahmad.

In a phone call to police on May 25 last year, Barry claimed Mr Ahmad was a rapist, a thief, a paedophile and a terrorist.

Barry had relapsed after he stopped taking anti-psychotic drug clozapine in November 2015.

He was drinking heavily, smoking skunk cannabis and behaving in a sexually inappropriate manner.

On June 13, he was sectioned under the Mental Health Act after being filmed on CCTV performing a sex act, wearing only a police hat.

He was taken to Callington Road Hospital in Bristol before being transferred to the Cygnet Hospital Kewstoke in Weston-super-Mare.

A mental health tribunal ruled on June 28 that Barry could be released, after he promised not to drink or take drugs.

Staff at the Milestones Trust were only informed of the decision a few hours before he returned to Wells Road.

They attempted to get an injunction to prevent him doing so, in an attempt to protect Mr Ahmad, but there was insufficient time.

At the close of Barry's trial, prosecutor Adam Vaitilingam QC told the jury there were "failings in the system".

"Whether the reasons are down to the system, or an individual, or a combination of both, you might feel that Kamil Ahmad was let down," he said.

"It is a system designed to protect an individual and protect society. I don't ask you to hold this against this defendant.

"Although he was manipulative and dishonest with the doctors in the tribunal, he is not to blame for failings in the system."

The court heard that the tribunal was unaware of how long Barry had been off clozapine, of his recent relapse, or of concerns raised by Milestones Trust staff.

Dr Roger Thomas, a consultant forensic psychiatrist, said Barry should have been detained for further assessment.

Barry arrived in Bristol at about 5.30pm on July 6 and went to two bars, where he consumed at least a litre of rum.

He used a telephone in the flats to call a helpline at 1am on July 7, telling a community psychiatric nurse he felt like "punching somebody".

CCTV images showed Barry knocking on Mr Ahmad's door at 1.30am and leaving, covered in blood, at 2.15am.

Neighbour Anthony Brink heard Mr Ahmad say "Oh no, it's you" and screaming after Barry went into the flat.

Barry later called 999 and reported that he had killed Mr Ahmad, stating: "Course it's murder, isn't it? I'm going to say diminished responsibility."

A post-mortem examination found Mr Ahmad had suffered injuries to his face, head and neck - with 25 stab wounds to his face and eyes.

There were fatal stab wounds to his stomach, right arm and left wrist. His penis had been cut off after death.

A Safeguarding Adults Review has been commissioned to examine the circumstances of Mr Ahmad's murder.