Iraq is close to all-out sectarian war as the Islamic State of Iraq and the Levant (Isis) massacres dozens of Iraqi soldiers in revenge for the loss of one of its commanders, and government supporters in Baghdad warn that the spread of fighting to the capital could provoke mass killings of the Sunni minority there.

One unverified statement from Isis militants on Twitter says that it has executed 1,700 prisoners. Pictures show killings at half a dozen places.

Isis has posted pictures that appear to show prisoners being loaded on to flatbed trucks by masked gunmen and later forced to lie face down in a shallow ditch with their arms tied behind their backs.

Final pictures show the blood-covered bodies of captive soldiers, probably Shia, who make up much of the rank-and-file of the Iraqi army. Captions say the massacre was in revenge for the death of an Isis commander, Abdul-Rahman al-Beilawy, whose killing was reported just before Isis’s surprise offensive last week that swept through northern Iraq, capturing the Sunni strongholds of Mosul and Tikrit.

Shia militiamen are pouring out of Baghdad to establish a new battle line 60 or 70 miles north of the capital. Demography is beginning to count against Isis as its fighters enter mixed provinces such as Diyala, where there are Shia and Kurds as well as Sunni.

In Mosul, from where 500,000 refugees first fled, the Sunni are returning to the city. Isis ordered traders to cut the price of fuel and foodstuffs, but religious and ethnic minorities are too terrified of

Sectarian strife looms as Shia join up to fight Isis to go home. “People in Baghdad are frightened about what the coming days will bring,” said one resident, but added that they were “used to being frightened by coming events”.

Baghdadis have been stocking up on food and fuel in case the capital is besieged. There is no sound of shooting in the city, though searches at checkpoints are more intense than previously and three out of four of the entrances to the Green Zone are closed.

Isis may be the shock troops in the fighting but their swift military success and the disintegration of four Iraqi army divisions have provoked a general Sunni uprising. At least seven or eight militant Sunni factions are involved, many led by former Baathists and officers from Saddam Hussein’s security services. But the most important factor working in favour of Isis is the sense among Iraq’s five or six million Sunni that the end of their oppression is at hand.

“The Shia in Iraq see what is happening not as the Sunni reacting justifiably against the government oppressing them but as an attempt to re-establish the old Sunni-dominated-type government,” said one observer in the capital. On both the Shia and Sunni sides the factors are accumulating for a full-scale bloody sectarian confrontation.

The surge of young Shia men into militias was touched off by the appeal of Grand Ayatollah Ali al-Sistani, the revered Shia cleric, for people to join militias. “The street is boiling,” said the observer.

Some 1,000 volunteers have left the holy city of Kerbala for Samarra which is on the front line, being the site of the al-Askari mosque, one of the holiest Shia shrines in a city where the majority is Sunni.

Asaib Ahl al-Haq, a Shia militia force close to the Iranians, is said to have recaptured the town of Muqdadiyah in Diyala and Dulu’iyah further west towards Samarra.

A problem in Iraq is that the country’s sectarian divisions are at their worst in areas where there are mixed populations: the country could not be partitioned without a great deal of bloodshed, as occurred in India at the time of independence.

The Sunni-Shia civil war of 2006-07 was centred on Baghdad and eliminated most mixed neighbourhoods, leaving those Sunni who had not already fled holding out in enclaves mostly in the west of the capital.

A cadre of advisers from the Iranian Revolutionary Guard Corps is believed to be putting together a new military force drawn from the army and militias. The regular army command has been discredited by the spectacular failure of the last 10 days.

ORDER IT NOW

The involvement of Shia militia fighters at the front increases the likelihood of mass killings of Sunni. This had started to happen even before the present offensive in Diyala province and at Iskandariya, south-east of Baghdad, where militants were said to be building car and truck bombs and where the Shia militiamen are said by witnesses to have adopted a “scorched-earth policy”.

Iraq has effectively broken up as the Kurds take advantage of the collapse of the regular army in the north to take over Kirkuk, northern Diyala and the Nineveh plateau.

The Kurds have long claimed these territories, saying they had been ethnically cleansed from there under Saddam Hussein. Many of these areas are rich in oil.

The government in Baghdad, though vowing to return to Mosul, has a weakened hand to play. Its military assets have turned out to be much less effective than even its most severe critics imagined.

If there is going to be a counter-attack it will have to come soon but there is no sign of it yet.

Isis has taken some of the tanks, artillery and other heavy equipment to Syria which might indicate that it doesn’t want to use it in Iraq.

But as a military force, it has recently depended on quick probing attacks and forays using guerrilla tactics, so its need for heavy weaponry may not be high.