The government has won its legal appeal to stop thousands of prison officers from staging a 24-hour protest over safety concerns in UK jails.

The Ministry of Justice (MoJ) went to the High Court to seek an injunction against the thousands of prison staff who essentially went on strike and only provided emergency cover following what the Prison Officers Association (POA) described as a "drastic increase in violence".

The High Court has now approved the injection to stop the walkout which Justice Secretary Liz Truss described as "unnecessary and unlawful".

A spokesperson for the POA said they have "consistently raised the volatile and dangerous state of prisons" with the government, highlighting "chronic staff shortages and impoverished regimes" as the main safety concerns for their staff.

A spokesperson added: "The continued surge in violence and unprecedented levels of suicide and acts of self-harm, coupled with the recent murder and escapes demonstrate that the service is in meltdown.

"The POA, as a responsible trades union, will ensure every prison has minimum cover arrangements in place to protect prisoner well-being security and safety, during this protest."

The protest follows on from a rise in assaults against prison staff, and a riot in HMP Bedford involving hundreds of inmates – with an estimated £1m ($1.2m) worth of damage was caused.

Official figures show that in the year to June, the number of attacks on prison staff rose by 43% to 5,954, which included 697 serious assaults.

Shadow Justice Secretary said the walkout is a sign the Tory government is "failing to address a prisons violence crisis which is leaving staff and prisoners in a dangerous situation."

He added: "It is clear that ministers have lost the confidence of prison officers as a result of workforce reductions and the daily experience of assaults on staff.

"The Justice Secretary needs to reassure the public and staff immediately that prisons are safe places to work."

The MoJ recently announced a £1.3bn investment plan in new prisons over the coming five years, which includes providing 2,500 extra officers, drug tests for prisoners and more autonomy for governors.

Responding to an Urgent Question in the House of Commons, Liz Truss said: "Prison officers do a tough and difficult job and I've been clear that we need to make our prisons more safe and secure."

The trial of Thomas Mair, the man accused of murdering Labour MP Jo Cox, was one of the court cases which had to be adjourned for the day as a result of industrial action. The walkout meant Mair was not be able to be escorted from custody to the court to attend his trial.

prison strike
Members of the prison service gather outside HMP Liverpool after officers stopped work in protest over working conditions Getty