Video footage has emerged online of a riot inside Bedford Prison which saw about 230 inmates go on a rampage as officers were forced to retreat to safety.

The video, thought to have been taken by an inmate using a prohibited mobile phone, shows chaotic scenes with scores of shouting prisoners out of their cells and flooding the jail's gangways.

Prison officers from across the country had to be drafted in to the category B prison in Bedford town centre after the disturbance broke out at around 5pm on Sunday (6 November).

The Prison Officers Association (POA) said inmates seized keys, broke into medicine stores and started small fires. Some guards were forced to retreat to a "safe place" as prisoners ran amok and took over two entire wings, the POA said.

It took officers more than six hours to get the prison back under control, with reports of loud bangs and explosions coming from inside.

No prison staff were hurt but two inmates were treated for injuries, which are not thought to be serious.

Officials did not say what sparked the riot, with unconfirmed reports in the media the violence may have been a reaction to poor conditions inside the prison.

A Prison Service spokesman said: "Specially trained prison officers and staff from the emergency services have successfully resolved an incident involving a number of prisoners at HMP Bedford.

"An investigation into this incident will take place. We are absolutely clear that prisoners who behave in this way will be punished and could spend significantly longer behind bars."

It comes after the head of the POA, Mike Rolfe, last week warned jails across the country had been engulfed by a "bloodbath", suffering record levels of violence following a toxic mix of overcrowding and an inadequate number of prison staff.

The government announced last week a £1.3bn investment plan in new prisons over the next five years, and plans for 2,100 extra officers, drug tests and more autonomy for governors.

Richard Fuller, MP for Bedford and Kempston, submitted a request for an urgent parliamentary question on Monday asking Justice Secretary Liz Truss to explain what had happened inside HMP Bedford. It was declined by the Speakers Office.

Fuller MP told IBTimes UK: "I want to know the reason why it started and how it was possible for this mobile phone footage to emerge."

He added: "There are some specific issues to do with HMP Bedford but national issues as well."

He pointed to a recent inspection which found standards inside HMP Bedford had declined to "unacceptable levels" after many previous recommendations had not been implemented.

The jail's 500 inmates were living in cramped conditions and suffering increasing levels of violence, the inspection in May found.

Inspectors said the jail was also plagued by drug problems with inmates telling them it was easier to get illegal substances than it was to get basic items like clothes or bed sheets.

Frances Crook, chief executive of the Howard League for Penal Reform, said the state of prisons are often to blame for rioting, adding that inmates at HMP Bedford were kept inside their cells for long periods at a time because of low staffing levels.

"If you lock people up in basically what amounts to a dungeon – it's dark, they're locked up almost all the time, they don't get enough food, they can't change their clothes, they can't get a shower, they can't phone home for days or even weeks on-end – you unlock the door, they come out fighting."