A ban on smoking and short-staffing led to a prison riot with inmates causing "many thousands of pounds worth of damage", a court has heard.
Luke Needham, 30, Andrew Alford, 41, and Deno Harrison, 23, are on trial at Winchester Crown Court charged with prison mutiny at HMP Erlestoke in Wiltshire.
Rob Welling, prosecuting, said that tensions rose during the weekend of June 11 and 12 2016, after prisoners were ordered to remain in their cells for the day because of a shortage of prison staff.
He said the situation had been worsened by two officers being required to escort a prisoner to hospital as well as raised tensions from a previous disturbance earlier that week.
He explained that the prison was category C meaning that it houses inmates of various levels of offending but who were not considered likely to attempt to escape.
Mr Welling said problems began after a national prison smoking ban was being trialled at the site.
He said: "As you can imagine it caused tensions to rise among prisoners as it was, frankly, a very unpopular move.
"And like other public bodies, the prison was short-staffed and if they couldn't safely supervise prisoners they would instruct a lockdown as happened on this occasion."
He said: "Tension was heavy and the atmosphere was very unpleasant and threatening."
He said the "slow process" of delivering meals to the cells by the short-handed staff prompted the unrest during the lockdown on the Saturday morning.
Mr Welling said Needham then set fire to his cell and flooded it before kicking open his wooden cell door and helping other prisoners to escape their rooms.
He added: "Prison officers were very short-staffed and heavily outnumbered and they took the decision they would have to evacuate, they grabbed their things and what they considered to be important
confidential papers and left the wing."
He said Needham and Harrison managed to get onto the rooftop and refused to come down until after midnight when a trained negotiator and back-up officers had arrived at the prison.
He said that after calm was restored on the Sunday a total of 120 prisoners had to be rehoused at prisons around the country and damage had been caused to the cells as well as to windows and CCTV systems.
Mr Welling said Alford had broken out of his cell on the other wing involved in the disturbance and had been involved in helping another inmate escape his room.
He said Needham refused to comment when questioned by police while Harrison said he had smoked the drug "Spice" and could not remember his actions.
He added that Alford had told police he had not intended to commit mutiny and said his "mental health was bad that day and he broke out of his cell because he could not breathe".
The trial continues.