The Government's controversial Mental Health Bill was tonight heading for the statute books after months of wrangling with the Lords and pressure from campaigners.
Accepting a final batch of minor amendments by peers, health minister Ivan Lewis acknowledged the legislation had proved contentious.
"There is no doubt also that the Bill has benefited from the vigorous debate that there has been during its passage," he added.
"We may not always agree about the exact nature of the provisions but the debate has enabled us all to understand the wide range of perspectives on the important issues raised by this Bill."
The legislation allows people with severe personality disorders to be detained if judged a threat to themselves or others.
It was introduced after several high profile murders involving people suffering from mental health problems but critics have warned its powers are too draconian and wide-ranging.
Peers inflicted a series of defeats over its provisions and the Government was forced to announce a series of changes in a bid to break the deadlock.
These included a compromise proposal drawn-up by Labour's Chris Bryant (Rhondda) giving new safeguards on powers to detain mental health patients.
The amendment introduces a new "treatability test" - ensuring that compulsory treatment must be of "therapeutic benefit".
Tonight, Mr Lewis told MPs: "It's been a long road to reach the point at this stage in the Bill."
He added: "In spite of past disagreements, we have the same aim as those who have debated every step of this legislation with us: the timely and effective treatment of all who need it."
The Bill is the latest stage in long-running Government efforts to introduce in England and Wales powers to detain people with serious personality disorders, even if they have committed no crime.
For the Tories, Tim Loughton said they would "certainly want to review" the measures if they got into office.
He said: "We will certainly want to review ... some of these quite radical and innovative, but unproven and untried measures, particularly with regard to compulsory treatment orders."
Mr Loughton was particularly concerned with the impact the measures will have on black and ethnic minorities and vulnerable patients.
The Government has been trying to introduce new mental health legislation since 1999 and Mr Loughton said: "After eight years in the gestation we want to make sure it's a Bill that's going to work for the benefit of very vulnerable people".
For the Liberal Democrats, John Pugh said there was still need for a "serious review" of mental health legislation and added: "Although the business here today will be concluded ... it is far from finished."
As MPs agreed to the amendments, Mr Lewis paid tribute to officials who had navigated the Bill through an "incredibly difficult and tortuous process".
He added: "I believe this will be seen as an historic piece of legislation which does represent the best interests of people with mental health needs and their families but also ensures the community can have confidence in a modern mental health system."