A key part of the legislation governing the long-term detention of around 100 people in psychiatric institutions is unconstitutional, the Court of Appeal has found.

However, the court suspended the declaration of unconstitutionality for six months, until 8 November to allow laws to be enacted to address the situation.

Mr Justice Gerard Hogan said he was doing this to avoid the "potentially catastrophic" consequences for the mental health system - whereby the legal basis for the detention of many vulnerable people would collapse.

Those affected include around 15 patients in the Central Mental Hospital and around 78 others.

Mr Justice Hogan said that if any of them were to be suddenly released due to the court's finding, it would be likely to have unfortunate consequences for their personal welfare and might pose a possible risk to the lives and safety of others.

He said the judiciary should not have to watch on helplessly as a finding of unconstitutionality leads on to invalidate and unravel a large variety of administrative decisions often in a "chaotic and disruptive" fashion with unforeseen consequences.

Mr Justice Hogan found that Section 15 (3) of the 2001 Mental Health Act was unconstitutional because it allows an involuntary patient to have their detention extended for up to 12 months without an effective procedure to have their detention independently reviewed within a reasonable time.

He said his finding demanded an immediate and imperative response from the Oireachtas and Government to bring in fresh legislation.

The appeal was brought by a man in his 30s who suffers from an intellectual disability.

He suffered a serious psychotic episode in 2015 and was admitted to hospital voluntarily.

But, despite recovering from the illness, he was detained in the psychiatric hospital because appropriate supported accommodation was not available for him.

Funding was eventually made available and he moved into the accommodation in September last year.

In his ruling, Mr Justice Hogan also acknowledged the devotion and care "evidently displayed" to the man by his parents, as well as medical professionals, teachers and carers.