BAGHDAD—Forty inmates in a prison in northeastern Iraq, including some convicted of terrorism charges, escaped amid a riot that killed at least six police officers and 30 prisoners, authorities said Saturday.

There were conflicting casualty reports on the attack at the Khalids prison in Diyala province. Two provincial police officials and a medical official put the toll much higher, saying 51 inmates and 12 policemen were killed, while more than 200 inmates escaped. They spoke on condition of anonymity as they were not authorized to release the information.

Brig. Gen. Saad Maan Ibrahim, the Interior Ministry spokesman, put the death toll at 36, including six police officers and 30 prisoners, and said 40 inmates escaped.

Ibrahim told The Associated Press that a fight broke out among the inmates of the prison and when guards went to investigate, they were overpowered and had their weapons taken. Some of those who escaped were wanted on terrorism charges, Ibrahim added. He said security forces had cordoned off the area and were hunting for the escaped inmates.

The town of Khalids is located about 80 kilometres north of Baghdad.

In a statement carried on militant websites, the local chapter of the Islamic State group claimed a completely different account of the incident, describing it as a co-ordinated operation involving the use of multiple explosives outside the prison. The statement claimed that 30 Islamic State members were among those who escaped.

Ibrahim had originally denied there was any external force involved and he did not immediately respond to requests for comment on the militants’ version of events.

Jailbreaks are common in Iraq and usually a result of assaults from militants seeking to free their comrades in prison. The most stunning one was in mid-2013, when militants carried out a carefully orchestrated attack with mortar shells and suicide bombers on Iraq’s infamous Abu Ghraib prison, freeing more than 500 inmates.

Meanwhile Saturday, a car bomb exploded in Baghdad’s central Karrada area, killing at least eight civilians and wounding 28, a police officer said. Among the dead were Shiite pilgrims preparing for next week’s major event commemorating the anniversary of the 8th century death of a revered religious figure, Imam Mousa al-Kazim. Thousands of pilgrims typically march to his shrine in northern Baghdad to commemorate his death.

No group immediately claimed responsibility for the bombing, but it bore the hallmarks of the Islamic State extremist group, which has carried near-daily attacks — along with other Sunni militant groups — against the Iraq’s Shiite majority, government officials and security forces.

The Islamic State group considers Shiites heretics. It captured large chunks of territory in western and northern Iraq last year, plunging the country into its worst crisis since U.S. troops left at the end of 2011.