Sunni lawmakers have pulled out of talks on forming a new Iraqi government after militants attacked a Sunni mosque in a volatile province outside Baghdad during Friday prayers, killing at least 64 people.

It was not immediately clear if the attack was carried out by Shiite militiamen or the Islamic State extremist group, which has been advancing into the ethnically and communally mixed Diyala province and has been known to kill fellow Sunni Muslims who refuse to submit to its leadership.

But Sunni lawmakers pointed to powerful Shiite militias, and two major parliamentary blocs pulled out of talks on forming a new Cabinet, setting up a major challenge for prime minister-designate Haider al-Abadi, a Shiite who is struggling to form an inclusive government that can confront the militants.

The blocs affiliated with Parliament Speaker Salim al-Jabouri and Deputy Prime Minister Saleh Al-Mutlak demanded that outgoing Prime Minister Nouri al-Maliki and the main Shiite parliamentary bloc hand over the perpetrators within 48 hours and compensate the families of victims "if they want the political process and the new government to see the light of day".

The joint statement blamed the attack on "militias" in an apparent reference to Shiite armed groups allied with the government.

An army officer and a police officer said the attack on the Musab bin Omair Mosque in Imam Wais village, 75 miles north east of Baghdad, began with a suicide bombing near the entrance, after which gunmen poured in and opened fire on the worshippers.

Officials in Imam Wais said Iraqi security forces and Shiite militiamen raced to the scene of the attack to reinforce security but stumbled upon bombs planted by the militants, which allowed the attackers to flee. Four Shiite militiamen were killed and 13 wounded by the blasts.

A total of at least 64 people were killed in the attack and more than 60 wounded. Mr Al-Maliki has called for an investigation.

The officials said Islamic State fighters have been trying to convince two prominent Sunni tribes in the area - the Oal-Waisi and al-Jabour - to join them, but that they have thus far refused.

Virtually all suicide bombings in Iraq are believed to have been carried out by Sunni militants, but Shiite fighters used the tactic in Lebanon during that country's civil war. In the chaotic aftermath of a major attack it is often not immediately clear how it was carried out or who was responsible.

Since early this year, Iraq has been facing an onslaught by the extremist Islamic State group and allied Sunni militants. The crisis has worsened since June, when the group seized Iraq's second largest city of Mosul, in the north.

In Diyala, Islamic State fighters have clashed with Kurdish forces guarding disputed territory claimed by the Kurdish regional government in the north. The extremist group pushed Kurdish forces out of the town of Jalula earlier this month after heavy fighting.

The Islamic State group has also clashed with Shiite militiamen and security forces loyal to the Shiite-led government in Baghdad. At the height of Iraq's sectarian bloodletting in 2006-2007 the province was among the country's most lethal areas.

If the attack proves to have been carried out by Shiite militiamen it would deal a major blow to Mr al-Abadi's efforts to reach out to the country's Sunni minority, whose grievances are seen as fuelling the insurgency.

Mr al-Abadi has until September 10 to submit a list of Cabinet members to parliament for approval, but such deadlines have often passed without action because of political wrangling.

Iraq's top Shiite cleric again called upon national leaders to settle their differences in a "realistic and doable" manner and swiftly form a new government to confront the Sunni insurgency.

Grand Ayatollah Ali al-Sistani said the next government should be made up of candidates who care about "the country's future and its citizens" regardless of their ethnic and religious affiliations.

Mr Al-Sistani warned that politicians' "demands and conditions could derail the forming of the new government."

The reclusive cleric's remarks were relayed by his representative, Abdul-Mahdi al-Karbalaie, during Friday prayers in the Shiite holy city of Karbala.

Mr Al-Karbalaie also called for urgent aid to be airlifted to residents of a small Shiite town which has been besieged by Sunni militants in northern Iraq.

About 15,000 Shiite Turkmen in the town of Amirli have been under a tight siege and are running out of food and medical supplies. The town is located about 105 miles north of Baghdad.

The United States launched air strikes this month to support Iraqi and Kurdish forces looking to reclaim territory seized by the Islamic State group.

US Central Command said that it conducted three new air strikes around the Mosul Dam, where clashes with militants continue nearly a week after Iraqi and Kurdish forces retook the sprawling facility with US air support.

Since August 8, the US has launched a total of 93 air strikes, of which 60 were near the Mosul Dam, Centcom said.