IN JUNE, when extremists from the Islamic State (IS) took over the Iraqi city of Mosul and hurtled south towards Baghdad, the Kurds in the north reacted with glee. They had no love for IS, a group which grew out of al-Qaeda in Iraq, later re-emerged in Syria and now operates in both countries. Indeed IS is sufficiently vile and disobedient, not to mention power hungry, that not even al-Qaeda likes it any more. But the Kurds saw its success as a deserved kick in the teeth for Nuri al-Maliki, the Shia prime minister. And if the fight with IS broke Iraq into sectarian pieces, semi-autonomous Kurdistan would achieve long-dreamed-of independence.

That sentiment disappeared at the beginning of August when, possibly as a result of resistance to the south, IS pivoted to take on the Peshmerga, the Kurdish armed forces. The Peshmerga number at least 120,000 and are reputed to be Iraq’s best-trained force. Before June IS was reckoned to have barely more than 10,000 fighters all told, though “they have doubled or tripled since this started,” according to Helgurd Hikmet of the Peshmerga. But the IS onslaught was brutal and well equipped, thanks to American hardware provided to the Iraqi government and then captured. Suicide-bombers were dispatched ahead of high-speed convoys; the troops showed an eagerness to die in battle rather than duck bullets. The Peshmerga admit that without American air strikes against IS, which started on August 8th, the fighting would have reached Erbil, their capital.

On August 10th the Peshmerga took back Gwer and Makhmur, two towns close to Erbil which had fallen to IS five days before. But that night the Kurds lost Jalawla, and IS continues to hold Sinjar and Zumar, two cities in north-western Kurdistan, as well as Mosul dam, which it seized on August 7th (see map). It has also claimed a number of towns peopled by Christians and Yazidis, minorities who have lived on the plains of Nineveh since pre-Islamic days.

Limited objectives

In the grounds of a church in Ainkawa, a Christian neighbourhood of Erbil, Christians talk of leaving. “There is no future for us in Iraq,” says Hani, a restaurateur and father of three. Yazidis, members of a small sect that takes inspiration from Zoroastrianism, have faced the prospect of total annihilation. Tens of thousands fled into the mountains above Sinjar to escape slaughter. Those who found safe passage back down told of bodies littering their path, some murdered by IS, others dead from starvation or heat exhaustion.

It was on the plight of the Yazidis and on “prevent[ing] genocide” that Barack Obama concentrated when he announced that America would again be intervening militarily in Iraq, almost three years after it withdrew its last troops from the country. In the first four days of air strikes, America’s manned planes and unmanned Predators carried out 15 air strikes on IS forces around Sinjar and to the west of Erbil. Meanwhile drones and surveillance aircraft carried out hundreds of intelligence flights in a scramble to understand the complex situation on the ground. Other aircraft, later joined by some from Britain, dropped supplies to the stranded Yazidis.

While most Iraqis, especially the Kurds, cheer at America’s reinvolvement in the country, American officials have been stressing the narrowness of the mission’s scope. In addition to defending American envoys in Erbil and Baghdad, and helping to break the siege around Mount Sinjar, Mr Obama listed just a few other limited objectives. America had to worry about “key infrastructure” in Iraq—referring to such assets as the Mosul dam. American efforts would also include “a counterterrorism element” to watch for jihadists who might launch attacks against Western targets. And America was talking about creating a “safe corridor” or some other mechanism to help Yazidis down from their sun-baked, waterless last resort. By August 14th, though, American forces had found that far fewer Yazidis remained on the mountain than previously estimated.

But although administration officials talk of IS as a broad threat to Iraqi and regional stability, as well as a seething cauldron of extremism that threatens to send hundreds of foreign passport holders back to their home countries trained to kill, America is not as yet embarked on a campaign to extirpate it. Mr Obama has repeatedly argued that IS has been strengthened by the Iraqi government’s mistakes, specifically its marginalisation of Arab Sunnis, who make up about a quarter of Iraq’s 33m population. If IS is to be turned back, Iraqi politics must turn around, too. Indeed, they must turn around first.

The Peshmerga say the forces they meet in combat are all IS. But Sunnis from disgruntled tribes, former members of Saddam Hussein’s regime and others who feel hard done by have all helped pave their way. Their support has included standing aside as IS men take control of their towns. Some Iraqis say that the Sunnis just never got over losing power when Saddam Hussein fell. But plenty, along with most Western governments, put the blame on Mr Maliki’s treatment of them. “This is not a cloud of locusts descending from nowhere,” says Peter Harling of Crisis Group, a Brussels think-tank. “It has been building up.”

Mr Maliki, prime minister since 2006, has always had sectarian and authoritarian tendencies. They were given freer rein after the Americans left in 2011. He kicked Sunnis out of the security forces, often in the name of “debaathification”. As discontent grew, he cracked down disproportionately: at a peaceful protest in the Sunni town of Hawija in April 2013 the security forces killed 50. After Falluja, a Sunni-majority city in eastern Anbar province, was taken over by rebels in December 2013, the army shelled it, and the security forces mounted a countrywide programme of mass arrests.

Awaken, again

The Kurds have grievances against Mr Maliki too. The government has refused to send Kurdistan its part of the national budget. In response the Kurds have started to export oil from fields under their control and keep the proceeds for themselves. Although the government in Baghdad resumed military co-operation with the Kurds when IS turned north, carrying out air strikes and ferrying weaponry to the Kurds, it was too little too late to make up for the bad blood. By early August even many of the MPs in Mr Maliki’s Shia State of Law coalition realised Iraq would only continue to fray if he remained in power. Mr Maliki’s removal thus became perhaps the only goal shared by Iraqis across all the country’s divides.

On August 10th Fouad Masum, Iraq’s newly installed Kurdish president (and the man who supervised Mr Maliki’s master’s dissertation in Arabic language and literature in Erbil) appointed Haider al-Abadi to the post of prime minister, which had been vacant since the May elections. Mr Abadi is viewed by Iraqis as less divisive than Mr Maliki—but that is a low bar. It hardly bodes well that the new prime minister is a man from the same party as Mr Maliki and with a similar outlook, subject to similar Iranian influence and hemmed in by the same hollowed-out institutions and acrimonious politicking. He now has 30 days to form a cabinet.

Creating a government sufficiently inclusive to win back the trust of Sunnis, and thus undermine IS, will be no easy task. Confidence-building measures such as releasing Sunni prisoners would probably be blocked by Shia parties while the IS emergency continues. Other demands such as incorporating Sunnis back into the security forces, most likely by creating a force in the Sunni areas nominally under central command, would take months if not years. Discussions on creating a more federal Iraq that devolves more power are likely to be necessary. Until the Sunnis are persuaded that such reforms offer a better alternative, IS will remain “an insurance policy”, says Ramzy Mardini, a visiting scholar at the Atlantic Council, a Washington, DC-based think-tank.

Like America and the UN, Iran, the country with the most influence in Baghdad since the Americans left, praised Mr Abadi’s nomination. It also appears to be restraining Mr Maliki, who is challenging Mr Masum’s decision in the courts, from going so far as to trigger armed confrontations between various militias and factions in the security forces. Asa’ib Ahl al-Haq, a powerful Shia militia, and Ayatollah Ali Sistani, Iraq’s top Shia cleric, have signalled their support for Mr Abadi too. Like Iran, Iraq’s Shias are rattled by IS and may be willing to make some concessions to the Sunnis to get rid of it.

Congratulating Mr Abadi on his nomination, America’s secretary of state, John Kerry, held out a list of incentives to the swift formation of an inclusive government: more American military help; economic aid; and support in resolving a row over the sharing of Iraqi oil revenues, among other disputes. With a nod towards the central government’s sensitivities, Mr Kerry was also careful to stress that Kurdish leaders had assured him of their support for a strong federal government.

In Kurdistan, meanwhile, the Peshmerga, perilously under-equipped during the fighting in early August, are rearming. The French are supplying some arms, and Pentagon commanders have vowed to make sure that the Peshmerga have access to the same sort of firepower that IS fighters have acquired, leaving open the possibility of supplying American arms.

America has no shortage of warplanes in the region, officers say; the USS George H.W. Bush, an aircraft-carrier, is nearby. But America downplays any idea that IS can be defeated with firepower alone. In a notably gloomy briefing on August 11th, Lieutenant-General William Mayville, director of operations at the Joint Staff, was at pains to make clear that American power was not “somehow breaking the momentum of the threat” posed by IS. Announcing the deployment of 130 additional troops to the Erbil region America’s defence secretary, Chuck Hagel, stressed that this was “not a combat boots-on-the-ground operation” (see Lexington). Officials said the troops would work on the safe corridor for the stranded Yazidis, though such an effort now seems unlikely; air strikes and Peshmerga counter-attacks have made it easier for them to escape.

America is convinced that only Iraq’s Sunnis can rout the extremists; hence the inducements to the new government to get them on board. The 2007-08 defeat of al-Qaeda in Iraq, IS’s predecessor, was made possible by the fighting of Sunni groups known as the Sahwa, whose work was accompanied by targeted assassinations by the Americans. The programme faltered when the Americans, who had been financing the Sahwa, withdrew, and Mr Maliki stopped the payments.

Meanwhile, next door

Quashed by the Sahwa and Americans, the forces which would grow into IS lay low before Syria’s civil war, which started in 2011, allowed them a chance to regroup. More ambitious than ever, IS now has a stronghold in Raqqa and controls oilfields, agricultural land and dams. Its high-ranking commanders are still mostly Iraqi, but it has attracted foot soldiers from Syria and beyond. Most of Syria’s Sunnis are on the whole a lot less tolerant of IS than Iraq’s are; other rebel groups hate it. But Bashar Assad, Syria’s president, has largely let the group be, using it as a scary portent of what would come if he were to fall.

In the first part of the year a sustained campaign against IS by other Syrian rebels pushed it out of some areas in the northwest of the country. However, armed with booty from Iraq, IS is starting to fight back, reportedly taking some towns close to Aleppo on August 13th. Syrian rebels fear that if IS gets squeezed in Iraq, it will focus on Syria—where American air strikes are most unlikely. Mr Obama draws a clear distinction between Iraq and Syria. American officials note that their actions in Iraq are at the invitation of the national government—putting them on the right side of international law and eliminating the need for UN or other international mandates.

The success IS has had in Syria has not gone unnoticed by President Obama’s critics. His former secretary of state, Hillary Clinton, told the Atlantic magazine that the “failure” to help build up a credible fighting force of anti-Assad rebels had left “a big vacuum, which the jihadists have now filled”. Mr Obama strongly disputes that charge, calling it a “fantasy” that weapons handed to an opposition made up of former doctors, farmers, pharmacists and other civilians could battle a well-armed Syrian state backed by Russia, Iran and the Hizbullah militia. Some of his own former officials, though, note that the president is, in theory, signed up to training and arming just such moderate rebels; if it is really a fantasy, why bother?

Iraq’s future hinges heavily on developments in Baghdad. If there is no progress, few predict anything less than a disaster. The most pessimistic say it is already too late—“Iraq is de facto divided and this is a war to delineate the borders,” says Mr Hikmet. Iraqis can do little but hope that their politicians act more responsibly than usual. Even then, IS will prove a problem for the region for years to come.