Alarming new military advances by Sunni extremists have finally forced Iraq’s disastrous prime minister, Nouri al-Maliki, to put the future of his country over his political disputes. On Monday, he ordered the Iraqi air force to support Kurdish forces battling to prevent extremists from taking even more territory and further threatening Iraq’s existence as a sovereign state.

The decision was needed to deal with the Islamic State group, which began as an al-Qaida affiliate and has been a major rebel force fighting in Syria, then jumped the border, captured the northern Iraq city of Mosul on June 10 and expanded from there.

Over the weekend, the group claimed its latest success, seizing control of three more towns in northern Iraq and threatening the country’s largest dam. The Islamic State group’s goal is to create a caliphate straddling Iraq and Syria, governed by a harsh interpretation of Shariah, and, in pursuit of that objective, it has been cracking down brutally on Christians, Yazidis and other minorities.

Its latest victory was particularly worrisome because the Islamic State group went up against the pesh merga, the security forces of the relatively secure and prosperous semi-autonomous Kurdish region that have been considered the country’s best motivated, best trained and best equipped military since the fall of Saddam Hussein’s army in 2003.

One explanation may be that the captured towns were not traditional Kurdish strongholds but inhabited by Yazidis and other minorities and hence were more vulnerable. Still, the takeover is a very bad omen — for the Kurds, who administer other towns such as Kirkuk with a mixed ethnic makeup; for thousands of Iraqis fleeing the violence; and for the United States, which invested much blood and treasure in a country now in danger of becoming a terrorist sanctuary.

After Mosul’s rapid fall, some believed the gains were possible largely because of the rapid collapse of Iraqi army units and Sunni anger with the country’s Shiite-led government. But the weekend fighting showed the group to be even more effective than earlier thought and has shaken assumptions that Baghdad itself, a Shiite stronghold, could not be taken.

Testifying recently before Congress, Brett McGurk, the State Department’s top Iraq expert, called the Islamic State group “worse than al-Qaida,” saying that it had moved from being a terrorist organization to a “full-blown army,” flush with money, weapons and foreign recruits.

Kurdish officials have promised a major counteroffensive against the Islamic State group, but whether al-Maliki’s offer of air support can turn the tide is unclear.

Having ignored repeated warnings about the Islamic State group, al-Maliki, forced now by necessity, has agreed to cooperate with the Kurds militarily. But there is still no end to the political paralysis among Kurds, Sunnis and Shiites that has prevented the selection of a new prime minister who can unify Iraq and credibly confront the extremists. No matter what it may cost Iraq, al-Maliki seems determined to hold on to the job even though Iran, the United States and many Iraqis have turned against him and the militant threat grows more perilous.