Disabled people have the same right to "physical liberty" as others, one of the UK's most senior judges has said.
Lady Hale, deputy president of the Supreme Court, said the state had a duty to uphold that right and to cater for those with disabilities.
The court ruled three disabled people living in supported accommodation had been illegally deprived of their freedom under mental health legislation.
Charities called for new guidance.
The judgement, which overturns decisions by the Court of Appeal, is likely to have far reaching consequences for thousands in similar circumstances.
The three individuals - two sisters with learning difficulties and a man with cerebral palsy - need intensive support to carry out basic tasks and have no capacity to determine what is best for them.
There had been no debate as to whether their care arrangements were appropriate.
The court concluded their liberty had been deprived as they would have been prevented from leaving their accommodation.
Seven Supreme Court justices ruled that deprivation of liberty had to be authorised under the terms of the Mental Capacity Act (2005) and living arrangements regularly checked.
European Human Rights legislation did apply to the trio, the court ruled, and other similar individuals had the right to a regular assessment of the appropriateness of their care.
Speaking after the ruling, Lady Hale said: "It is axiomatic that people with disabilities, both mental and physical, have the same human rights as the rest of the human race."
Human rights "have sometimes to be limited or restricted" because of disabilities, but the basis for freedoms should be the same for everyone, she said.
This was not changed by the fact many people were detained in comfortable care facilities, she said, because a "gilded cage" was "still a cage".
The state had a "duty to make reasonable accommodation to cater for the special needs of those with disabilities", she added.
'Hugely complicated issue'
Charities working with disabled people said the ruling was a "landmark" for the protection of people with mental illness.
Mark Lever, chief executive of the National Autistic Society (NAS), said the ruling was "a victory for the rights of vulnerable people ".
"This landmark [ruling] makes it clear that people with autism have the same right as anyone else," Mr Lever said.
Mind, which campaigns for people with mental illness, said the judgement provided "much-needed clarity on a hugely complicated issue".
Chief executive Paul Farmer added: "We call on the government to urgently issue clear guidance to care providers and local authorities so that they can implement this judgment."
Lawyers who represent disabled people also welcomed the ruling.
Last week, a House of Lords committee found laws covering those in hospitals or care homes were being flouted regularly.
The committee said it was likely many people were having their liberty deprived illegally.