Mourners at a funeral of an Iraqi soldier killed during clashes with ISIS militants in Ramadi (Alaa Al-Marjani/Reuters)

When Sunni militants seized the Iraqi city of Mosul at the start of the week, instantaneously creating half a million refugees and an existential crisis for the country, it came as a surprise. The Islamic State of Iraq and Syria (ISIS) has been terrorizing Iraq for months now, but when it along with other jihadi forces and Baathists still loyal to Saddam Hussein’s regime took the nation’s second-largest city, the threat became more serious. As ISIS pledges to advance south toward Baghdad, Iraqi soldiers are in many cases abandoning their posts and stripping off their uniforms to escape. It’s a terrifying development, but it shouldn’t come as a complete shock. Iraq is disintegrating, and ISIS’s success is just a distillation of the problems the country has been struggling with for some time now.

The roots of the current violence go at least as far back as Iraq’s 2006-2007 civil war, which didn’t so much end as get put on hiatus. The spate of sectarian violence pitted the Shiite-majority government against Sunni militias and al-Qaeda in Iraq (a group from which ISIS emerged). The U.S. troop “surge” halted the bloodshed and got Sunni groups to side with the government against foreign jihadists. But it failed to produce a greater political resolution. With the departure of American forces from the country in 2011, these grave tensions reemerged.

Iraq’s 2006-2007 civil war didn’t so much end as get put on hiatus.

Making matters worse, Nouri al-Maliki, Iraq’s Shiite prime minister, has been on a political warpath. His judiciary sentenced Iraq’s Sunni vice president to death in absentia on allegations of leading death squads. He’s also used ISIS’s incursions at the end of 2013 into Anbar province, in the country’s northwest, to crack down on Sunni protesters. At the same time, the autonomous northeastern region of Iraqi Kurdistan remains in conflict with the central government over its oil exports, namely a pipeline built by the regional government without national approval. In this poisonous atmosphere, violence has spiked, with almost 9,500 civilians killed from car bombs and other attacks in 2013 alone—the worst figures since 2008. Last month 799 Iraqis perished—in the highest death toll this year. ISIS’s seizure of the cities of Fallujah and Ramadi has only further stoked this violence. The Iraqi army has attempted to recapture both, with limited success.

But Iraq’s political crisis may not have morphed into a full-blown emergency if not for the grinding civil war in neighboring Syria, which has become a geopolitical pawn in the region. Shiite-led Iran has backed the regime of Bashar al-Assad, while the Sunni-led Saudi Arabia and the Gulf Cooperation Council it spearheads have supported the rebels, including extremist groups. The war, which has already killed more than 160,000 people, has sent more than 200,000 refugees to Iraq, many of them Iraqis who fled to Syria over the past decade. With the rest of the international community unable to do much about the conflict, thanks in part to UN Security Council opposition from Russia, Syria has become a hotbed for foreign jihadists, and they’re quickly growing more powerful than the more moderate anti-Assad opposition.

As the war’s dragged on—it’s now in its fourth year, with no sign of letting up—these hard-core jihadi groups are targeting anti-government rebels in addition to the government (to the Assad regime’s benefit). ISIS is one of the most powerful of these jihadi groups, having split off from the Syrian branch of al-Qaeda last year. But ISIS has also turned east in its bloody campaign to establish an Islamic state, pushing through Anbar province—notably along lucrative oil hotspots—toward Baghdad. As Aaron Zelin, an expert on jihadi movements, noted on Thursday, “Iraq is now a key part of the same quandary that Western leaders have been attempting to figure out in Syria for some time.” The one military force that’s proven capable of fighting ISIS is the Kurdish Peshmerga. But beyond taking in some refugees from Mosul and assuming control over the oil-rich city of Kirkuk, the Kurdish Regional Government hasn’t indicated that it will take further action to aid the country as a whole.

Iraqi leaders are now confronting not only highly motivated and well-financed jihadists but also anti-government opportunists who’ve joined them. As ISIS has taken Mosul and then the city of Tikrit, springing prisoners, scoring military equipment, and seizing money along the way, Shiite militias in and around Baghdad have pledged to protect their holy sites, which stand along the militant group’s current path. Maliki has pleaded with the United States for assistance, while also turning for help to his ally, Iran. A resurgence of sectarian violence could be in the offing, as the long-festering conflicts in Syria and Iraq threaten to merge into one great regional war.