The woman, named only as MH, lived in Shropshire, where she was taken into hospital on mental health grounds in January 2003, initially for assessment.
Her mother tried to have her discharged but the hospital blocked the request on the grounds that the woman would have been a danger to herself and others.
Social workers then applied to the local county court to "displace" the mother as her nearest relative. That application had the effect of extending MH's detention indefinitely.
She was eventually released in July 2003 but judicial review proceedings were begun against the health secretary.
MH complained that her right to challenge the lawfulness of her detention had been violated because there was no provision under UK law for the automatic review of the detention of persons without legal capacity.
Her lawyers also argued that there had been no provision for a patient, whether incapacitated or not, to take proceedings before a court or tribunal when the detention had been extended indefinitely.
In a unanimous judgment, the court in Strasbourg held that the UK had violated the woman's right to liberty during the first 27 days of her detention.
It ordered the UK government to pay the woman, who is now in her 40s, compensation of €4,400 (£3,730). She also received a similar sum for her legal costs.
The judges said: "It is clear that special safeguards are called for in the case of detained mental patients who lack legal capacity to institute proceedings before judicial bodies. However, it is not for this court to dictate what form those special safeguards should take."
Story Written by Owen Bowcott