After eight years and three separate attempts, the government has finally succeeded in getting its mental health bill passed in the House of Commons.
Government proposals to incarcerate mental health patients regardless of whether their condition is treatable caused fierce controversy among mental health groups and civil liberty campaigners.
Those parts of the bill have now been watered down following a serious of amendments by Labour MP Chris Bryant.
Incarceration will now require some evidence of therapeutic benefit.
The government first tried to reform the 1983 Mental Health Act in 1999. Draft bills published in 2002 and 2004 were categorically rejected by psychiatrists and mental health campaigners.
The second draft bill was then savaged by a parliamentary committee. The government dropped it in March 2006, albeit with the intention of resurrecting the most controversial aspects of it in future legislation.
The government's commitment to incarcerate people with severe personality disorders stemmed from the killing of Lin and Megan Russell by Michael Stone in 1996. Mr Stone suffered from a personality disorder and could not be detained because his condition was untreatable.
The murder convinced the government to close that loophole in treatment but opponents claimed that authorised the state to imprison people who had committed no crime.
The government appears to have backed down over the proposals, however, and today's bill states that no patient can be detained in hospital for a purpose other than to improve or prevent deterioration in their health.
The change meant the bill, which now requires the Royal Assent, has been accepted by the Mental Health Coalition, an influential group of 78 organisations including the Royal College of Psychiatrists (RCP), the Law Society and Mind.
The coalition vigorously opposed previous versions of the bill and staged a lobby of Parliament last year in protest.
It says it welcomes the therapy-dependent standard which detention must satisfy, the granting of advocates to those who will be detained, and the inclusion of a clause guaranteeing child patients are treated in environments suitable for their age group.
Julia Scott, chief executive of the College of Occupational Therapists said: "The amended bill will ensure that the focus of services will be on those who need them, that their views and needs will be better represented and understood, and that the staff who deliver services for them will be better placed to meet their needs."
But the RCP remained concerned the bill overrules patients' treatment preferences.
"The government has failed to recognise that most people who suffer from mental illnesses are perfectly capable of making decisions for themselves, and present no threat to anyone," the college said.
"Yet, under the mental health bill, they will still have their choice of treatment overruled."
Sheila Hollins, president of the college, said: "The college has worked very hard to try to ensure that the mental health act 2007 respects the human rights of our patients, with the intention of benefiting their health and protecting them from causing any harm whilst unwell."
Vice-president Tony Zigmond added: "Although important and valuable changes have been made to the bill as it passed through parliament, it is clear we will have to wait for the next mental health act to see adequate and humane safeguards for both patients and the public."