An Iraqi government air strike on a Sharia court set up by Islamic State militants in the northern Iraqi city of Mosul has killed 60 people, the office of the prime minister's military spokesman said.

The Islamic State judge who ran the court was among those killed, the spokesman said.

The Sunni militants routinely hand down sentences such as beheadings.

Hospital officials and witnesses said earlier that the air strike had killed 50 people in a makeshift prison set up by the Islamic State.

Mosul has been under insurgent control since June, but there have been hit and run attacks by government forces and allied Kurdish peshmerga fighters.

Separately, five bomb attacks killed at least 30 people and wounded around 70 others today in several Baghdad districts, Iraqi police and medical sources said.

The Islamic State jihadist group seized large parts of Iraq's west and north in June, before stopping its offensive a few dozen kilometres from the Iraqi capital.

But violence has continued to wreak havoc in Baghdad, mostly in Shia neighbourhoods, with suicide attacks, car bombs and improvised explosive devices targeting security forces as well as civilians.

Meanwhile, around 50,000 members of Iraq's Yazidi ethnic minority are hiding on a mountain in northern Iraq following an offensive by Islamic State fighters over the weekend.

A senior Kurdish official said they are hiding near the town of Sinjar and risked starving to death if they are not rescued in 24 hours.

"Many have already died," said Jabbar Yawar, secretary-general of the ministry of the Kurdish peshmerga fighters.

His comments came as Kurdish forces attacked Islamic State fighters just 40km southwest of the Kurdish regional capital of Arbil.

"We have changed our tactics from being defensive to being offensive. Now we are clashing with the Islamic State in Makhmur," said Mr Yawar.

He said the Kurds had re-established military cooperation with the government in Baghdad.

Ties had been strained between the Kurdish leadership and the Shia-led government of Prime Minister Nouri al-Maliki over oil, budgets and land.

But the weekend offensive by the Sunni militants prompted them to bury differences and work together against the biggest threat to Iraq's security since the fall of Saddam Hussein in 2003.