A group of about 50 people due to be deported to Jamaica on Tuesday morning won a last-minute reprieve on Monday night following an emergency ruling by the court of appeal.

The court ordered the Home Office not to remove anyone scheduled to be deported from two detention centres near Heathrow on the 6.30am flight to Jamaica – “unless satisfied [they] had access to a functioning, non-O2 sim card on or before 3 February”.

The action was brought because there has been a problem with the O2 phone network in the Heathrow detention centres since last month, meaning many detainees had been unable to exercise their legal right to contact their lawyers.

The Home Office tried to have the decision overturned but that attempt failed just before 1am on Tuesday morning.

Bella Sankey, director of Detention Action, which brought the legal challenge, said: “We are delighted with this landmark decision which is a victory for access to justice, fairness and the rule of law.

“On the basis of this order from our court of appeal, we do not believe that anyone currently detained at the Heathrow detention centres can be removed on [Tuesday’s] flight. We understand that this will apply to at least 56 people.”

Lawyer Toufique Hossain, who brought the case for Detention Action, said: “For weeks now detainees’ complaints have fallen on deaf ears. Their removal looms large, hours away and yet again it takes judicial intervention to make the Home Office take basic, humane and fair steps to allow people to enjoy their constitutional right to access justice.”

The Home Office had argued that the flight was “specifically for deporting foreign national offenders”, adding that “those detained for removal include people convicted of manslaughter, rape, violent crime and dealing Class A drugs”.

The 11th-hour reprieve came as a result of one of two actions to try to halt the flight. Earlier a high court judge rejected an application from solicitors on behalf of 13 Jamaican-born men due to be put on the flight.

The lawyers argued that the home secretary, Priti Patel, had acted unlawfully by forcing the men on to the plane, had breached human rights legislation and denied them adequate access to legal advice.

Their application to the high court to halt the flight added that the Home Office’s announcements in the media and in parliament about the charter flight would make the men being deported a “public spectacle” in Jamaica, and place them at risk.

The appeal court has been asked to consider that high court ruling, and was expected to make another out of hours ruling on that overnight.

Some individuals due to fly have won the right to stay in the UK for the time being, after a separate application to the upper tribunal of the immigration chamber. They include Akeem Finlay, whose solicitor Naga Kandiah welcomed the decision, but condemned the Home Office’s plan to deport so many men who would leave partners and children behind.

“It seems there is an inherent disregard for the integrity of the family unit and the welfare of children,” he said.

Rishi Sunak, the chief secretary to the Treasury, said those being forcibly removed had committed “very serious offences”. But 13 detainees due to fly today described a range of less serious offences they had committed.

More than 150 cross-party MPs had called on Boris Johnson to halt the flight, citing a range of concerns.

Hossain said many of the people on the flight had lived in the UK for most of their lives and that there needed to be a proper overview and consideration given to how the Home Office approached such individuals.

Sankey said: “Our information indicates that most have been convicted of drugs-related offences – often only once – and several have been groomed into county lines operations.”

The Home Office has not responded to recommendations from the former prisons ombudsman Stephen Shaw or to a leak from the Windrush Lessons Learned review, which suggested that foreign national offenders who had lived in the UK for most of their lives should not face automatic deportation.

Last year the Guardian revealed that at least five men had been murdered after their deportation to Jamaica. One of the five was Dewayne Robinson, 37.

It has emerged that Robinson was the cousin of Akeem Finlay, 30, one of those who is facing enforced return to Jamaica on Tuesday after a GBH conviction. Finlay came to the UK at the age of 10.

Months before Robinson’s murder on 4 March 2018 after his deportation from the UK, another of Finlay’s cousins was murdered. “The men involved in the murders of my cousins have warned our family not to return to Jamaica or we will be murdered too,” said Finlay.