The Government is facing a legal challenge over a loophole that allows thousands of people with learning disabilities or mental health problems to be detained in hospitals without the right of appeal.

This week, the European Court of Human Rights will hear a landmark case brought by the carers of an autistic man who has spent most of his life in care.

The man, known only as Leonard for legal reasons, was kept for more than four months in Bournewood psychiatric hospital in Surrey against the wishes of his legal guardians, known as Mr and Mrs E.

They are challenging current legislation that allows hospitals to hold patients who, because of their condition, cannot communicate if they want to leave hospital.

The Department of Health estimates that there are as many as 50,000 people in Britain who do not have the capacity to express their views and therefore could be detained under current laws.

Mental health charities say the legislation violates the human rights of patients. Simon Foster, the principal solicitor for Mind, said that the Government needed to act as soon as possible to ensure the rights of the mentally ill and learning disabled are upheld. "This case illustrates that vulnerable people need a much higher level of protection," Mr Foster said. "Mentally ill people need consistency and this practice is anti-therapeutic."

The Independent on Sunday is campaigning for better rights for the mentally ill, especially those who are patients in special hospitals. The paper has already highlighted the plight of those who languish in special hospitals when they should be accommodated in medium-secure units.

In 1997, Leonard, who is now 54, was sent to Bournewood psychiatric hospital after he became upset by a woman screaming on the bus on the way to his day centre. He was detained on the orders of a consultant psychiatrist for four and a half months.

Mr and Mrs E eventually won an independent assessment that allowed him home. They found that his clothes were soiled, he had lost two stone in weight and he had blood pouring from a wound in his head where he had hurt himself.

They won a High Court ruling which declared it unlawful for hospitals to hold adults, without legal procedures, simply because they could not say they wanted to go home. This ruling was overturned in 2001 by the House of Lords.

Last year, the NHS Ombudsman condemned Bournewood for forcibly detaining Leonard and said that he should never have been held in the first place.

The Home Office has included provisions in the draft Mental Health Bill that will allow patients such as Leonard to have legal protection from being detained.

Bournewood hospital did not provide a comment on Leonard's legal challenge. However, they have publicly accepted the findings of the Ombudsman's report and have apologised to Mr and Mrs E.