Emergency laws to deal with "irregularities" in the sectioning of up to 5,000 mental patients have been rushed through the Commons.
The Government had admitted 2,000 doctors involved in decisions to lock up between 4,000 and 5,000 mentally ill people had not been properly approved.
Ministers only learned of the problem last week when a doctor questioned an approval panel's processes.
Queries later revealed four of England's Strategic Health Authorities - North East, Yorkshire and Humber, West Midlands and East Midlands - shifted responsibility for authorising doctors who assess patients for sectioning from the SHAs to mental health trusts.
Health Secretary Jeremy Hunt said new legislation was needed to bring absolute legal clarity to the situation, which has been going on for 10 years.
Speaking as MPs debated the Mental Health (Approved Functions) Bill, Mr Hunt said: "We believe there are good legal arguments as to why the detentions that are currently taking place as a result of approvals made by the doctors in these four SHAs are and were legal.
"Why, if that is the case, do we feel the need for emergency legislation, retrospective legislation? It's a very reasonable question to ask.
"We believe there is legal precedent as to why, in a situation as sensitive as this, a court in deciding whether a detention was lawful or unlawful would look to what the will of Parliament was when it passed the original law.
"But because of the technical irregularity, the doctors who made this decision in the four SHAs, that could be challenged.
"That is the reason. It's because it is so important to put those decisions beyond doubt, with respect to this narrow technical issue."