The Home Office has agreed to carry out an independent and far-reaching inquiry into alleged abusive treatment of immigrants held in UK detention centres after being threatened with legal proceedings.

Facing mounting pressure over its network of 10 sites, which handle more than 25,000 immigrants every year, the Home Office finally caved in to pressure to investigate how detainees were being treated following allegations of abuse at a site near Gatwick airport.

BBC Panorama exposed abuses at Brook House immigration removal centre in September 2017. Following that exposé, two linked legal challenges against the Home Office were launched.

The Home Office said in a letter seen by the Guardian that it would conduct an independent investigation if the legal action was called off. The terms of the inquiry have not yet been agreed but it would be carried out by the prisons and probation ombudsman (PPO).

Don't go to dangerous countries – unless the UK is deporting you Read more

“The Home Office has now requested that the prisons and probation ombudsman undertake a dedicated, bespoke, independent … investigation,” the letter said. “This is in addition to the multiplicity of inquiries and investigations which have already taken place.”

The decision to agree to open up to scrutiny comes after a volley of revelations about the Home Office’s system of detaining, often indefinitely, immigrants theoretically earmarked for deportation, many of whom are mentally or physically ill, suicidal or victims of torture.

On Thursday, a freedom of information response from the Home Office acknowledged that suicide attempts in detention centres had jumped more than 20% in recent months, with almost two a day on average through the summer period.

Dozens of former and current detainees have spoken to the Guardian in recent weeks of their time in detention centres. Some said guards were sympathetic, others said they had been poorly treated. One, Savita Vyas, said she felt like “an animal being taken to the slaughterhouse”.

Secret video filmed at the Harmondsworth facility showed detainee frustrations boiling over into protest.

Play Video 0:45 A protest inside Harmondsworth detention centre – video

The Guardian reported on Wednesday that a snapshot of detainees sampled on 31 August found more than half fitted the definition of “adults at risk”. The median detention time was four months. More than 80% had been given no idea how long they would be held for.

The BBC’s Brook House documentary, based on undercover footage shot by a detention officer, revealed extensive physical and verbal abuse of detainees by officers.

It showed one officer appearing to throttle one man and threatening to put him “to sleep” before detention and healthcare staff conspired to cover it up.

Brook House is run by the private contractor G4S, which has conducted its own review into the allegations of abuse.

Quick guide Britain's immigration detention system Show Hide How many people does Britain lock up, pending deportation? More than 27,000 people were detained in 2017, according to the most recent figures. At any one time, there may be up to 3,000 people in detention. In 1993 there were 250 detention places. By 2005 there were 2,644 places. Where are they held? Detainees are held in eight detention centres and two ‘short term holding facilities’. Eight are in England, one in Scotland and one in Northern Ireland. Some can be held for months, even years. A Guardian survey of 200 detainees found average term length is about four months. Who are they? The nationality of detainees change over time. The Guardian survey found Nigeria and Algeria were most commonly represented among our responses, while Home Office open data for the second quarter of 2018 showed that South Asian countries made up the largest proportion of detainees. TDetainees are overwhelmingly male - women made up just 15% of the total detention population in 2017.

In the wake of the documentary, two men have asked the Home Office to launch an independent inquiry into the failings of detention centres. The Home Office initially refused to do this. To date no criminal charges have been brought against any of the officers shown to be behaving improperly in the documentary.

Lewis Kett of Duncan Lewis solicitors, who brought one of the two legal challenges, said: “Our client was suicidal, vulnerable and helpless. He was pinned down, strangled and degraded by officers who were supposed to be responsible for his care. They conspired to cover it up, obviously thinking that the scarce oversight of their work meant it would never come out. Only the brave decisions of an undercover officer allowed this to be exposed.”

Immigration detention: 'It's basically a death sentence' – the Story podcast Read more

Joanna Thomson, a solicitor at Deighton Pierce Glynn, said: “Panorama revealed shocking, deliberate abuse of detainees by detention staff. That was probably only the tip of the iceberg. Staff were shown bragging about how they mistreated vulnerable detainees and how they cover up the evidence. It is imperative that the Home Office now acts quickly to give the PPO the powers needed to make this investigation effective.”

David Isaac, chair of the Equality and Human Rights Commission, said: “We supported the claimants in this case as there appeared to be deliberate acts of humiliation and abuse that cannot go unanswered in a civilised society.

“The Home Office has a duty to ensure an independent investigation takes place, and we welcome today’s announcement. We will be scrutinising this investigation to ensure that human rights breaches are rectified, and sufficient measures are put in place so that they never happen again.”

A Home Office spokesman said: “The Home Office has asked the PPO to undertake a dedicated, special investigation … The PPO has agreed in principle to conduct an investigation although the terms of reference are yet to be agreed.”