The Prison Officers Association has been fined £210,000 for two "deliberate breaches" of an anti-strike injunction.
The POA admitted inducing a national strike by prison officers in September 2018 and supporting industrial action at HMP Liverpool in February.
Two High Court judges said the association appeared "to have behaved as if it is above the law".
The union said it was considering an appeal against the judgment.
The Ministry of Justice (MoJ) took legal action to enforce a High Court order made in 2017 which prevents the POA from "inducing, authorising or supporting any form of industrial action by any prison officer".
The union argued the injunction represented a "disproportionate interference" with the right to freedom of association and should not have been made.
Lady Justice Simler and Mr Justice Cavanagh rejected the POA's argument, finding that the union "was and remains bound by the terms of the injunction and... has breached those terms".
They added: "The exceptional nature of the prison environment means that the risks and potential consequences of the withholding of services by prison officers are grave."
The judges said prison officers provided "a truly essential service", and that any limits on their right to strike were justified.
They said the POA "appears to us to have behaved as if it is above the law, and literally to have shown contempt for solemn court orders with penal notices".
They added: "We accept that there is no evidence of actual harm caused as a result of either incident, and that both were relatively short-lived. However, the potential risks and consequences were grave."
The POA said it was a "disappointing result" its "struggle for justice will continue".