ALMOST OVERNIGHT, the Islamic State sent its enemies reeling—and turned U.S. policy in the Middle East upside down. Islamic State forces carved out a haven in Syria and, in June 2014, routed the Iraqi army, capturing large swathes of territory and prompting the Obama administration to overcome its long-standing aversion to a bigger U.S. military role in Iraq and Syria. Even in many Arab countries where the Islamic State does not have a strong presence, its rise is radicalizing those countries’ populations, fomenting sectarianism and making a bad region even worse.

But there is one person for whom the Islamic State’s rise is even more frightening: Ayman al-Zawahiri. Although the Al Qaeda leader might be expected to rejoice at the emergence of a strong jihadist group that delights in beheading Americans (among other horrors), in reality the Islamic State’s rise risks Al Qaeda’s demise. When Islamic State leader Abu Bakr al-Baghdadi rejected Al Qaeda’s authority and later declared a caliphate, he split the fractious jihadist movement. The two are now competing for more than the leadership of the jihadist movement: they are competing for its soul.

Who will emerge triumphant is not clear. However, the implications of one side’s victory or of continuing division are profound for the Middle East and for the United States, shaping the likely targets of the jihadist movement, its ability to achieve its goals and the overall stability of the Middle East. The United States can exploit this split, both to decrease the threat and to weaken the movement as a whole. Washington must also adjust its counterterrorism policies to recognize the implications of this rivalry.

AL QAEDA emerged out of the anti-Soviet jihad in Afghanistan in the 1980s. As the Soviets prepared to withdraw, Osama bin Laden and a few of his close associates—high on their perceived victory over the mighty Soviet Union—decided to capitalize on the network they had built to take jihad global. Bin Laden’s vision was to create a vanguard of elite fighters that could lead the global jihad project in a clear, strategic direction. His goal was to bring together under a single umbrella the hundreds of small jihadist groups struggling, often feebly, against their own regimes. By the mid-1990s, he wanted to reorient the movement as a whole, focusing it on what he saw as the bigger enemy underwriting all these corrupt local regimes: the United States.

Al Qaeda’s emphasis on fighting the “far enemy” (the United States) over the “near enemy” (repressive regimes in the Muslim world) was a break from the traditional jihadist agenda, but for local jihadists, pledging allegiance to bin Laden and adopting the Al Qaeda brand meant obtaining access to a wide range of assets: money, weapons, logistical support, expertise and, of course, training. Al Qaeda training camps were the Ivy League of jihadist education. For jihadists facing annihilation at the hands of their regimes, the choice was easy—join Al Qaeda, adopt an anti-Western agenda and live to fight another day.

The 1998 bombings of two U.S. embassies in Africa and the 9/11 attacks inside the United States transformed Al Qaeda into a potent brand. Although 9/11 electrified the global jihadist movement and further raised Al Qaeda’s profile on the world stage, the U.S. counterterrorism response that followed devastated both Al Qaeda and the broader movement it purported to lead. Over the next decade, the United States relentlessly pursued Al Qaeda, targeting its leadership, disrupting its finances, destroying its training camps, infiltrating its communications networks and ultimately crippling its ability to function. The death of the charismatic bin Laden and the ascension of the much less compelling Ayman al-Zawahiri to the top leadership position further diminished the power of the Al Qaeda brand.

Enter the Islamic State.

The Islamic State began as an Iraqi organization, and this legacy shapes the movement today. Jihadist groups proliferated in Iraq after the 2003 U.S. invasion, and many eventually coalesced around Abu Musab al-Zarqawi, a Jordanian jihadist who spent time in Afghanistan in the 1990s and again in 2001. Though bin Laden gave Zarqawi seed money to start his organization, Zarqawi at first refused to swear loyalty to and join Al Qaeda, as he shared only some of bin Laden’s goals and wanted to remain independent. After months of negotiations, however, Zarqawi pledged his loyalty, and in 2004 his group took on the name Al Qaeda in Iraq (AQI) to signify this connection. Bin Laden got an affiliate in the most important theater of jihad at a time when the Al Qaeda core was weak and on the run, and Zarqawi got Al Qaeda’s prestige and contacts to bolster his legitimacy.

Yet even in its early days the group bickered with the Al Qaeda leadership. Zawahiri and bin Laden pushed for a focus on U.S. targets, while Zarqawi (and those who took his place after his death in 2006 from a U.S. air strike) emphasized sectarian war and attacks on Sunni Muslims deemed apostates, such as those who collaborated with the Shia-led regime. Zarqawi and his followers also acted with incredible brutality, making their name with gruesome beheading videos—a tactic that AQI’s successor organizations would also use to shock and generate publicity. Despite Zawahiri’s misgivings, Zarqawi’s strategy seemed to work well, as AQI mounted a broad insurgency and for several years controlled some of the Sunni-populated parts of Iraq. In public, Zawahiri and bin Laden continued to embrace their Iraqi affiliate.