The mysterious visit to Moscow in late July by Iran’s international troublemaker-in-chief, the shadowy head of the feared Quds Force, may just have found an explanation. It’s either terrifying or vaguely reassuring, depending on how you read the Middle East. Specifically, how you feel about the Moscow visit will depend on whom you’d rather see winning the Syrian civil war, Bashar al-Assad or the Islamic State group.

You might prefer a third option. But there isn’t one. There never was. Alas, the choices are the mass-murdering, Iran-allied tyrant or the terrorist super-group that’s dragging the Middle East back to the eighth century. Some of us wish America would go in and settle things. Unfortunately, we tried that in Iraq and Afghanistan. It backfired.

Then again, you might be the sort who wouldn’t mind seeing Syrians keep on fighting, figuring that as long as they’re killing each other they’re not attacking Israel. But with the explosion of the refugee crisis, that idea has become not just unconscionable, but also pointless. The exodus is both a humanitarian disaster and a regional security nightmare. And it can’t be stemmed until the fighting stops.

The immediate problem is that there are three main camps fighting for control of Syria, and none shows signs of quitting. One is the Assad regime, reinforced by Iran and its Lebanese militia, Hezbollah. The second is the Islamic State group. The third is the so-called mainstream opposition, a gaggle of feckless, squabbling grouplets that recalls nothing so much as the anti-Roman underground in “Monty Python’s Life of Brian.”

Washington, Europe and the Saudis have been trying since the war started in 2011 to get the mainstream opposition groups to cooperate and put up a fight, but nothing seems to work. Any groups that show some spunk usually turn out to be wings of Al Qaeda or of the Muslim Brotherhood.

There is also a fourth camp, the Kurdish militias. They’re among the best anti-regime, anti- Islamic State fighters, but they have no ambitions beyond being left alone in their villages.

Enter the Moscow visitor, Gen. Qasem Soleimani. His Quds Force is the elite foreign-operations arm of the paramilitary Iranian Revolutionary Guard Corps, responsible for terrorism and covert operations outside Iran’s borders. He’s barred from international travel under United Nations sanctions. Any country that receives him is violating international law.

His reported July 24 visit to Moscow drew a sharp protest from Washington, a lame semi-denial from Russia, then confirmation from Iran. Reuters reported that Soleimani was discussing “regional and bilateral issues” and weapons shipments with Russia’s president, Vladimir Putin, though it’s unclear why Iran would send a paramilitary operative to discuss diplomacy.

Now, Israeli defense officials are suggesting what may be the trip’s real purpose: to firm up a joint Russia-Quds Force operation in Syria in order to prop up what’s left of the Assad regime. Reports in Ynet and Haaretz quoting unnamed Israeli officials said Soleimani sent hundreds of Quds Force troops in early September to link up with Russian troops in Syria’s main Mediterranean seaport, regime-controlled Latakia. Intelligence sources in the United States report separately that Russia is building an air traffic control tower and prefab housing in Latakia for up to 1,000 personnel.

Russia’s entry shouldn’t surprise us. Moscow has serious interests to protect in Syria, beginning with its naval base at Tartus, Syria’s other main port, 50 miles south of Latakia. It’s Russia’s only base on the Mediterranean littoral. Though mostly unused since the Soviet Union collapsed, it’s still a significant asset in Putin’s great-power ambitions. Russia needs Assad to maintain control of the coast if nothing else.

The regime currently holds a strip running south along the coast from the Turkish border to the Lebanese border, then wrapping east and south around Lebanon until it reaches the Israeli-held Golan Heights.

And that’s where Israel’s dilemma begins. After Syria failed to retake the Golan in the 1973 Yom Kippur War, it’s been Israel’s least troublesome border. The two countries signed a disengagement agreement in 1975, and Syria has observed it scrupulously. Syria says awful things about Israel and makes trouble through Hezbollah proxies in Lebanon, but those things aren’t in the agreement. From a military-security point of view, Syria has been a good neighbor.

Until the civil war. Before 2011, Syria was an Iranian ally. Now it’s essentially an Iranian possession. Iran is far more hostile toward Israel than Syria is, far more determined to make trouble. Iranian and Hezbollah troops have been touring the Golan frontier, probing Israeli defenses, exchanging fire. The future bodes ill.

The regime currently controls just the northern part of the border. Most of the Golan frontier, running south to the Jordanian border, is loosely controlled by mainstream rebel groups, the secular Free Syrian Army and the Al Qaeda-affiliated Al Nusra Front. They’re pressed by Hezbollah from the north and by the Islamic State group from its stronghold to the east, in the southern suburbs of Damascus.

Persistent reports say Israel is quietly cooperating with Al Nusra against Hezbollah and the Islamic State group. But Al Nusra and the entire mainstream are losing ground. The fight is coming down to a battle between the Russia-Iran-Assad alliance and Islamic State.

Which is worse? Israel’s political and military echelons have been arguing about that for years. Prime Minister Benjamin Netanyahu says Iran is the primary existential threat because of its nuclear potential and expansionist ambitions. Netanyahu’s battle against the Iranian nuclear agreement has only strengthened his view. Saudi Arabia and the Gulf emirates agree.

But for most of Israel’s military leadership and for much of the West, the Islamic State group is the bigger problem. Iran has shown that it responds to a mix of negotiation, deterrence, threats and firm punishment. It’s a dangerous foe, but it plays by a known set of rules. The Islamic State group doesn’t. Nobody has yet found a way to stop it. It grows like a cancer, beheading, enslaving and attracting enthusiastic young Muslims by the thousands.

David Petraeus, former CIA director and former commander of U.S. forces in the region, splits the difference. He told The Atlantic’s Jeffrey Goldberg in July that the Islamic State group is more dangerous to America and the West because its strange appeal to young diaspora Muslims creates an internal security threat. But in the region, Iran is more dangerous because of its destabilizing activities.

That may be true for the Saudis, who fear Iran’s Shia theology no less than its military mischief. Israel’s concern is just security. The Islamic State threat grows continually, while Russia’s entry, paradoxically, reduces the Iranian threat. With Russia on the scene, security officials say, Israel has someone to talk to on the other side. When Iran allies itself with the far more powerful Russian military, it’s essentially accepting certain limits on its own mischief-making.

Soleimani’s Moscow visit may violate sanctions, outrage Washington, terrify the Saudis and worry Netanyahu. But everyday Israelis, knowing the Russians are coming, can sleep a little easier.