The Overseas Operations (Service Personnel and Veterans) Bill has been voted through at third reading in the House of Commons.
It cleared by 345 votes to 260, with a majority of 85.
An amendment from Tory former minister David Davis, to ensure the bill’s provisions to block prosecutions would not apply to torture, was defeated by 269 votes to 334, with a majority of 65.
Earlier, Minister for Defence People and Veterans Johnny Mercer said the bill “does not decriminalise torture”.
He told MPs: “I am very much aware that many people have misinterpreted the decision to only exclude sexual offences from the presumption against prosecution, including suggesting that it somehow undermines the UK’s continuing commitment to upholding international Human Rights Law and humanitarian law – including the UN Convention against Torture.
“This, as my honourable friends well know, is completely untrue.
“The UK does not participate in, solicit, encourage or condone the use of torture for any purpose and we remain committed to maintaining our leading role in the promotion and protection of human rights, democracy and the rule of law.
“The bill does not decriminalise torture or war crimes and it will not encourage or allow our service personnel to act with impunity.
“We will continue to take other offences such as war crimes and torture extremely seriously. The severity and the circumstances in which it was committed will always be factored in the prosecutor’s considerations.”
Speaking during the report stage debate on the bill, Mr Davis had told the Commons: "The Judge Advocate General, who I described earlier, has said the following – 'In my view, what this bill does is exactly the opposite of what it is trying to do.
"'What it is trying to do is stop ambulance-chasing solicitors and vexatious and unmeritorious claims. The minister has quite rightly said we want rigour and integrity.
"'What it actually does is increase the risk of service personnel appearing before the International Criminal Court. That is why I said it was ill-conceived' – that is the Judge Advocate General, the most expert person in the country on this subject.
"And he also described, incidentally, the bill as bringing UK Armed Forces into disrepute.
"Now, if the Government really thinks that schedule one did not make justice more difficult to deliver then it would not have excluded sexual offences from the remit of the bill.
"If it is not difficult to get a prosecution, why exclude any category? It was right to exclude and it should also exclude torture on exactly the same grounds – and that is the point of the amendment in my name and in the name of many others."
Defence Secretary Ben Wallace said the bill does not prevent military personnel from prosecution for crimes they may have committed.
Addressing the Commons, he said: “This bill is more than just a manifesto commitment, it is a necessary and overdue strengthening of the legal framework for dealing with the vexatious claims and repeated investigations that have arisen from recent overseas military operations.
“There have been many inaccurate and wild accusations about the measures in this bill. It does not prevent Armed Forces personnel from being prosecuted for crimes they may have committed. It does not remove prosecutors’ independence or ability to prosecute on the basis of any new or compelling evidence for any crime at any time.
“It does not undermine the UK’s adherence to the UN Convention against Torture, commitment to international law, or willingness to investigate and prosecute any alleged criminal offences.”
Mr Wallace added: “The Government has listened to many of the contributions throughout the bill progress, but we’ve been unable to accept these amendments as they would undermine rather than strengthen the bill.”
An SNP amendment, which aimed to exclude the prosecution of serious international crimes such as torture and genocide from the limitations imposed by the bill, was defeated by 262 votes to 335, with a majority of 73.
Labour Shadow Defence Secretary John Healey argues that the UK can do "so much better" than the legislation as it stands.
He told the Commons: “This is a bill to deal with long-running problems that have arisen under successive governments, Labour and Conservative, and the minister in charge was right when he just said we must do better.
“But we can do much better than this bill as it stands. We want this to be a bill that protects British troops and their right to justice, a bill that protects Britain’s reputation as a force for good in the world, upholding universal human rights and a rules-based international order.
“But in truth, the closer people look at this legislation, the less they like it.”
Conservative MP Tom Tugendhat, who chairs the Commons Foreign Affairs Select Committee, said that the bill does not go far enough.
He told the Commons: “You can absolutely see time and again in operations the opportunity for an individual with nefarious intent trying to bring legal action against the MOD in order to prevent operations.
“You can see again and again how legal intervention could be used to try and prevent operations and the absurd element of that is that actually, it prevents the Armed Forces doing exactly what they’re there for.
“It prevents the Armed Forces being the strong defending the weak and what instead it means is that soldiers who are deployed on lawful operations will not be able to act in defence of the most vulnerable.
“It is absolutely clear that this bill is intended to go some way towards meeting that and I do have a criticism of this bill, I don’t believe it goes far enough.”
One of the key aims behind the bill has been to limit false and historical allegations against service personnel and veterans in relation to overseas operations.
While not an absolute ban on historic prosecutions, the bill would make it exceptional for serving personnel and veterans to be prosecuted five years or more after an incident that took place during overseas operations.
About 70% of allegations received by the independent Iraq Historic Allegations Team were dismissed as there was no case to answer, according to the Government.