The Home Office “falsely imprisoned” many asylum seekers who are now entitled to damages for their loss of liberty at the hands of the government, five supreme court judges have ruled.

Thousands of asylum seekers are likely to be affected, many survivors of torture, trafficking and other forms of persecution. Their compensation could run into millions of pounds.

The people implicated in the ruling were locked up between 1 January 2014, when an EU law known as Dublin III came into force, and 15 March 2017, when UK regulations changed.

Under the Dublin regulations, asylum seekers should claim asylum in the first EU country they reach, with the receiving country checking their fingerprints against a European database. If they are found to have first claimed asylum in another EU country they can be sent back to that country to have their claim processed.

Many of those people for whom the Home Office found a fingerprint match in another EU country were locked up in preparation for removal to that country.

However, under the Dublin III rules only those deemed to be at “significant risk of absconding” should be incarcerated before removal.

Wednesday’s ruling, by judges Lord Kitchin, Lady Hale, Lord Reed, Lord Wilson and Lady Arden, found that the Home Office was locking up asylum seekers without having proper policies in place to determine whether an individual posed this risk.

The precise number of asylum seekers affected by the ruling is not known. Until last year, the Home Office did not publish detailed data about Dublin III cases. According to research on the Dublin rules from the House of Commons library, published earlier this month, the UK made 18,953 transfer requests between 2015 and 2018. During the same period, 7,365 requests were made by other EU countries to transfer asylum seekers to the UK.

The Home Office said: “We acknowledge the supreme court’s judgment and are considering the next steps.”

Krisha Prathepan, part of a team at Duncan Lewis Solicitors, which brought the successful supreme court challenge, welcomed the ruling and called on the Home Office to conduct an urgent review to identify exactly how many people were falsely imprisoned between 2014 and 2017. They will now be entitled to compensation for suffering and loss of liberty.

“This is a brilliantly clear and forceful judgment which has huge implications for those detained for the purposes of removal under the so-called Dublin III regime between 1 January 2014 and 15 March 2017,” said Prathepan.

“The right to liberty is a fundamental human right. The impact of this judgment is profound – yet again the home secretary’s policies in relation to detention have been found to be unlawful. Her actions have caused untold misery for so many people – including many vulnerable victims of torture and trafficking, and people suffering from PTSD and other mental health conditions who never should have been detained in the first place.”

Emma Ginn, the coordinator of Medical Justice, which advocates for health rights for immigration detainees, welcomed the ruling. She said: “Medical Justice volunteer doctors have assessed many detainees who are Dublin III cases to document their scars of torture.

“Many of them have survived perilous overland journeys from places like Iran and Eritrea. Many are victims of torture and trafficking and are already in poor health when they get detained in the UK. It is now widely accepted that immigration detention can retraumatise torture victims, that it can exacerbate existing health issues and can cause severe harm and mental illness.”

Five asylum seekers brought the supreme court case: a woman from Iran, two men from Afghanistan and two men from Iraq. Four arrived in the UK smuggled inside lorries, and a fifth arrived in the back of a train. All five were detained for varying amounts of time ranging from one month to four months.

The judges said the case raised “important points of principle”.

The Home Office argued that its detention rules adequately covered the Dublin III criteria, but the judges said its arguments were not “persuasive”.

Of the Home Office guidance that was in place between January 2014 and March 2017, they said: “All of this amounts to no more than general guidance as to how the power to detain is to be exercised and does not constitute a set of objective criteria against which the risk of absconding is to be assessed.”

The judges stressed that the right to liberty was a fundamental right. The judgment cites the five asylum seekers’ arguments that the Home Office’s failure to adhere to a published policy without good reason can amount to an “abuse of power” that renders detention unlawful.

“They were detained without lawful authority and their detention amounted to false imprisonment and they are entitled to damages,” the judges concluded.