Ruling, which was attacked by the defence secretary and chief of the defence staff, leaves MoD open to compensation claims

The Ministry of Defence breached English law, Afghan law, human rights legislation and international law by allowing British troops to detain Afghans for long periods without trial, the high court has ruled in a judgment with potentially huge implications for military commanders.

The ruling, which was immediately criticised by Philip Hammond, the defence secretary, and General Sir Nick Houghton, chief of the defence staff, means the MoD also faces the prospect of demands for substantial compensation. Hammond said the government would appeal.

The case was brought by lawyers acting for Serdar Mohammed, a Helmand farmer captured by British troops on suspicion of being an insurgent. He said he was tortured into giving a false confession after being transferred to the Afghan National Directorate of Security (NDS) facility at Lashkar Gah.

He was held by British troops well beyond the 96-hour limit laid down by international forces in Afghanistan, before he was handed over to the NDS.

"Decisions were … made to adopt a detention policy and practices in pursuit of military objectives which went beyond the legal powers available to the UK," Mr Justice Leggatt ruled.

He added: "The consequence of those decisions is that the MoD has incurred liabilities to those who have been unlawfully detained".

Leggatt ruled that Mohammed's continued detention on a British military base was unlawful because it was illegal under Afghan law, under the Human Rights Act and under international humanitarian law. He said it also breached international law since it was not authorised by the UN security council resolution, which provided the mandate for the UK and other national forces in Afghanistan.

In a devastating passage, the judge said his conclusion that [Mohammed's] detention after 96 hours was unlawful "will not come as a surprise to the MoD". It was apparent from documents he had seen that the MoD formed the view at an early stage that there was no legal basis on which UK armed forces could detain individuals in Afghanistan for longer than the maximum 96 hours authorised by international Nato-led troops in Afghanistan.

Leggatt added: "Legal advice also confirmed that there was no basis upon which UK forces could legitimately detain individuals for longer periods in the interest of interrogating them because they were believed to have information of intelligence value."

As the MoD itself recognised in a memo in 2006, "the reality of the legal basis for our presence in Afghanistan is such that available powers may fall short of that which military commanders on the ground might wish."

Leggatt noted: "Nothing happened subsequently to alter that reality."

Hammond said in a statement issued immediately after the ruling: "We cannot send our armed forces into battle with both hands tied behind their backs. Our troops engaged in operations must be able to detain our enemies who aim to maim and kill UK service personnel and innocent civilians." He said that if the MoD did not succeed in its appeal, the government would "examine other options open to us". He added: "We will not allow our combat effectiveness to be constrained by this judgment."

Hammond has already said that ministers were contemplating a change in the law to exclude military commanders from a succession of judgments by British courts relating to the Human Rights Act.

However, Thursday's ruling went beyond the Human Rights Act by charging the MoD with breaches of international humanitarian law as well as Afghan law and UN rules.

Houghton described Leggatt's judgment as "one which causes me operational concerns".

He added: "It sits within a wider context where legal and safety issues, conceived for civilians in peace time, are being applied in an operational context. Our freedom to conduct detention operations and to exploit detainees for intelligence is vital to our ability to protect the lives of innocent civilians and our own forces. Any judgment which might inhibit our ability to operate in ways which minimise casualties and protect our people is deeply worrying."

Leigh Day, the law firm representing Mohammed, said that while UN security council resolutions may have given British troops the right to capture him, they did not confer a right to hold him incommunicado for over four months.

"When we send our troops abroad it is the Ministry of Defence's job to ensure that the mechanisms are put in place to ensure that they operate within the rule of law," it said. "As the court has made clear, the MoD fully understood the parameters of the law regarding detention and yet they decided to operate flagrantly outside those rules."

Phil Shiner of Public Interest Lawyers, which acted for three other Afghans detained by British troops for more than nine months, described Thursday's judgment as "of profound importance" for future UK operations abroad. "It tells the MoD again that no matter how they try to avoid accountability for the UK's actions abroad, international human rights law will apply and, thus, UK personnel must act accordingly," he said.

Leggatt said that Mohammed's detention solely for the purpose of interrogation was in breach of the European human rights convention, and "arbitrary".

He ruled: "It is now apparent that when push came to shove and detainees could not be transferred to Afghan custody within 96 hours – either because there was considered to be a real risk of ill treatment or, as in the present case, because there was not enough room in the Afghan prison – detainees were not released as the MoD had said would be necessary (because the UK had no legal power to detain them). Instead, they were imprisoned indefinitely on British military bases until transfer became possible. Moreover, that was done even though the MoD's own policy and procedures for detention did not authorise long-term detention in such circumstances."