Photo: Iraqi forces took back Fallujah from ISIS in late June, establishing full control over one of the jihadis’ most emblematic bastions. Moadh al-Dulaimi/AFP/Getty Images

There’s a school of thought that the recent surge of terrorist strikes, capped by Thursday’s mass murder in Nice, France, that has killed at least 84 people, is a sign of ISIS’s desperation—a response to shore up morale and reassert its relevance, in the face of its string of losses on the battlefields of Syria and Iraq.

It’s true that American airstrikes, Iraqi and Kurdish ground assaults, and the occasional raid by U.S. Special Forces have lately pummeled ISIS forces, severed their supply lines, and recaptured some of their strongholds. But it’s extremely unlikely that the spike of terrorist attacks for which ISIS has claimed credit (or for which the killers have claimed allegiance to ISIS)—in Orlando, Jordan, Lebanon, Istanbul, Baghdad, Saudi Arabia, Bangladesh, and now southern France, just in the past month—has any correlation with the ups and downs of tactical military operations.

For one thing, there hasn’t really been a surge of terrorist violence. As Brian Jenkins, a longtime analyst of terrorism at the Rand Corporation, noted in an article published in the Hill on Monday:

Similar spates of attacks have occurred from time to time. People tend to view them as evidence of escalation or a strategic shift, as something new and significant, when the cluster of activity is little more than a reflection of chance—several groups of attackers getting lucky at the same time and causing the world to take notice.

A similar spike took place, for instance, in January (well before any battlefield setbacks), with terrorist attacks in Libya, Iraq, Turkey, Afghanistan, Indonesia, and Egypt.

Bruce Hoffman, director of Georgetown University’s Center for Security Studies and senior fellow at the U.S. Military Academy’s Combating Terrorism Center, agrees.* In a phone conversation Thursday, he said that data indicate no relationship, one way or the other, between ISIS’s territorial gains or losses and its terrorist operations. It’s long been reported that the truly coordinated ISIS attacks—such as those in Paris and Brussels—took many months, in the case of Paris two years, to organize. In other words, they were initiated when ISIS was gaining territory, not losing it. Finally, though the two strands of ISIS operations—military operations in the Levant and terrorist strikes abroad—are part of the same overall goal, they are run as separate enterprises. In many cases (and not just recently), the terrorists in question have been “lone wolves” who were inspired by ISIS but not directed by any central organization.

French police sources have identified the driver of the truck as 31-year-old Mohamed Lahouaiej Bouhlel, who was not previously known to hold radical or Islamist views. ISIS Twitter accounts have cheered the results, but Rukmini Callimachi, the New York Times reporter who follows these accounts intensely, noted Thursday night that, in the past they have also applauded killings that turned out not to have involved ISIS at all.* She also tweeted that ISIS spokesmen have urged followers to use cars as weapons to kill infidels as far back as 2014 and as recently as last month. It’s as yet unknown whether the driver in Nice got his idea from those sources.

If ISIS continues to lose ground in Iraq and Syria (and apparently even its own spokesmen acknowledge that the caliphate may be on the verge of collapse), might the terrorists who invoke the caliphate’s name soon dry up, too? At some point, do followers stop following a cause that’s clearly lost?

Perhaps, but the problem here is that, though ISIS troops are losing, it’s not just good guys who are winning. In Syria, much of the resulting vacuum has been filled not by forces of stability (whoever they may be) but rather by competing jihadi groups—most prominently Jabhat al-Nusra, the Syrian offshoot of al-Qaida.

Brett McGurk, President Obama’s envoy to the region, told the Senate Foreign Relations Committee in late June that Nusra is “establishing schools and training camps, recruiting from abroad, launching major military operations, and enjoying a sophisticated online presence, all the while providing haven for some of al-Qaida’s most experienced terrorists.” Nusra also has “direct ties to Ayman al-Zawahiri, Osama Bin Laden’s successor,” making it, in McGurk’s words, “al-Qaida’s largest formal affiliate in history.”

Al-Qaida is also gaining ground in Libya and has launched some incursions as a rival to the Taliban in Afghanistan. In other words, while the Obama administration’s focus on ISIS has sired some tactical victories, it has not reduced the presence of jihadi extremists. Al-Qaida has ascended as ISIS has fallen—just as ISIS once ascended in the wake of al-Qaida’s near collapse. Georgetown’s Hoffman predicts that, in the next five years, ISIS and al-Qaida will merge or at least form a strategic alliance.

So what should the United States and the rest of the relatively civilized world do? Should we step deeper into this war, expanding our list of counterterrorism targets?

Secretary of State John Kerry met with Russian President Vladimir Putin in Moscow on Thursday night, presenting him with a formal eight-page proposal to create a joint Russian-American command—sharing intelligence and coordinating airstrikes—in an intensified campaign against ISIS and Jabhat al-Nusra.

The arrangement would require Syrian President Bashir al-Assad, who has been bombing and strafing opposition groups of all sorts (mainly those backed by the United States), to ground his country’s jets. Even if Assad were to agree to that, some analysts and officials are skittish about the proposal, understandably so. Putin has been far more interested in defending Assad’s regime than in going after ISIS or Nusra. (In Putin’s dictionary, any armed group in Syria, besides the Syrian army, is “terrorist.”) Nor has he exerted any pressure when his ally, Assad, has blatantly violated cease-fire agreements.

Kerry is also pushing Putin to get more seriously involved in the diplomatic process—established in Vienna late in 2015—to bring a halt to the Syrian civil war and to ease Assad out of power in a negotiated political transition. This is a tall order, to say the least, and it may not work, even if Washington and Moscow come to some agreement. The rest of the region’s players—Turkey, Iran, Saudi Arabia, Jordan, the UAE, among others—have a say in this; and, though they all fear and loathe ISIS and al-Qaida, many of them fear and loathe one another at least as much.

Unlikely as this venture is, it’s probably the only road to a peace, even a fragile one. Assad’s brutal suppression of his own Sunni citizens keeps the flame burning for jihadis everywhere; he is the top poster-boy for ISIS and Nusra recruitment drives. His removal and the formation of a new coalition government are prerequisites to any further progress. The leaders of Russia and Iran will block any such steps unless they’re assured, ahead of time, that their national interests will be protected—that they play a role in selecting the parties and policies of the new government. And what will the Sunnis, who detest Iran and distrust Russia, have to say about this?

Then, of course, there is Iraq. In one sense, Iraq is easier to fix than Syria because it’s known what needs to be done, but it’s no easier to go about doing it. The Shiite-led Baghdad government must share power and resources with Iraq’s Sunnis and Kurds. Or Iraq must be split up into three separate states or a very loose federation. (Then–Sen. Joseph Biden and Leslie Gelb proposed such a federation back in 2006, at the height of the post-invasion civil war and insurgencies. Most analysts scoffed at the time, but it looks like a good idea now. The main obstacle back then was that no Iraqi political factions wanted to split up, and Iraq was after all deemed to be a sovereign nation. Some of its factions wanted to reconcile and share power; most wanted to fight for all of it. Too bad.)

Iraqi Prime Minister Haider al-Abadi is more inclined to political outreach than his predecessor, Nouri al-Maliki, but, ever since America’s 2003 invasion, and even more since its 2011 withdrawal, Iran has stepped into the power vacuum; Iranian-backed militias have seeped into the Iraqi security forces, and very little of any significance can happen in Iraqi politics without Tehran’s assent.* At least this situation—and the slow but steady re-emergence of the Iraqi army as a competent force, backed by U.S. logistics, intelligence, air power, and Special Forces—has prevented al-Qaida or its offshoots from establishing a base in Iraq. There’s only ISIS to deal with, and its foothold is shrinking. But Sunni resistance will remain a factor, and sectarian struggles will remain tense, without a political settlement—which, in Iraq’s case, would involve Iran’s willingness to curtail some of its geopolitical ambitions for the sake of regional stability. So far, there’s no such sign on the landscape.

These are some of the many reasons why the modern Middle East is such a mess, and probably will remain a mess for a long time to come. If winning wars, making peace, and stopping terrorism were as easy as Donald Trump seems to think, they would have been won, made, and stopped long ago.

Correction, July 15, 2016: This post originally misidentified Georgetown University’s Center for Security Studies as the Center for Strategic Studies. It also misspelled the last names of Rukmini Callimachi and Nouri al-Maliki.