Health Secretary Jeremy Hunt says urgent retrospective legislation is needed to correct a "technical error" affecting up to 5,000 patients sectioned under the Mental Health Act since 2002.
The error means doctors who sectioned patients in England did not have the right jurisdiction to do so.
Mr Hunt insists all were qualified to make the clinical decisions and none of the patients was wrongly detained.
He has ordered an independent review.
Mr Hunt said: "We believe that all the proper clinical processes were gone through when these patients were detained. They were detained by medically qualified doctors. We believe that no one is in hospital who shouldn't be and no patients have suffered because of this.
"But for the avoidance of any remaining doubt, and in the interests of the safety of patients themselves, as well as the potential concerns of their families and the staff who care for them, we are introducing emergency legislation to clarify the position."
A patient can be sectioned if they are perceived to be a threat to themselves or other people.
Generally, a patient can only be sectioned if two doctors and a mental health professional believe it is necessary.
Doctors who assess patients, and make recommendations under the Mental Health Act, are required to be 'approved' to do so by the Secretary of State.
Since 2002, the Secretary of State has delegated that approval function to Strategic Health Authorities (SHAs).
However, four out of the 10 SHAs in England asked mental health trusts to carry out the validation and approval process for them, but did not ask for it to be referred back to them for final confirmation.
This is the error that Mr Hunt says needs rectifying as a matter of urgency.
He said up to 2,000 doctors working for the four SHAs - North East, Yorkshire and The Humber, West Midlands and East Midlands - did not have the right approval to section patients sent to hospitals that included Ashworth and Rampton Secure Hospital.
The Department of Health has asked Dr Geoffrey Harris, chairman of NHS South and former chairman of Buckinghamshire Mental Health Trust to undertake an independent review to look at how this responsibility was delegated by these four SHAs; and, more broadly, the governance and assurance processes that all SHAs use for delegating any responsibilities.
He will report back to the Secretary of State by the end of the year.
All doctors involved have now been approved under the correct processes.
Paul Jenkins, Chief Executive of Rethink Mental Illness, said: "All of us need to know that if we were ever ill enough to be sectioned, we would be treated according to the proper processes.
"At this stage, we have no reason to think that anyone has been detained who should not have been, even though the correct procedures have not been followed.
"We believe that the Department of Health and Strategic Health Authorities are taking swift action and we will continue to monitor the situation."
Paul Farmer, Chief Executive of the mental health charity Mind, said: "We welcome the independent review announced by the Secretary of State and look forward to working with the review team and the government to establish exactly what has happened and why."