Members of the Prison Officers Association had walked off the job today morning, although they said they would respond to emergencies. They called the walkout a protest, rather than a strike.
Prison guards are barred from striking and the government asked the court to rule the protest unlawful.
Judge Tim Kerr said the guards should go back to work. He said "a number of incidents have occurred in prisons today and the situation is very concerning indeed."
Justice Secretary Liz Truss said the walkout was "actively putting people at risk of harm," but a lawyer for the prison officers' union said it was the Conservative government that had failed in its duty to provide "a safe place and a system of work."
More From This Section
The union says prison violence and inmate suicides are rising. Earlier this month, 200 prisoners rioted at Bedford Prison in southern England, and two inmates escaped from London's Pentonville Prison.
The government says it is recruiting 2,000 new guards to bolster the system, but the union says "the service is in meltdown," with poor morale making it hard to retain staff.
Today's walkout led to court hearings being abandoned because prisoners couldn't appear in court. Jurors in the murder trial of Thomas Mair, the man accused of killing lawmaker Jo Cox, were sent home for the day.