More than four years into Syria’s civil war, a series of significant military defeats for Damascus and a historic diplomatic breakthrough with Tehran have thrust the gears of a long-stalled peace process back into motion.

In recent weeks, a sudden flurry of diplomacy aimed at resolving the crisis has seen officials from Iran and Russia, who have kept Syrian President Bashar al-Assad’s regime afloat for years, hold rare talks with their counterparts in the rebel corner, namely the United States, Saudi Arabia and Turkey. Then on Monday, the U.N. Security Council unanimously approved a statement that called on all sides to “work urgently” on implementing the 2012 Geneva agreement, which has been stalled over Assad’s potential role in a transitional government. U.N. envoy to Syria Staffan de Mistura has even announced the resumption of “working group”-style talks next month.

After more than 250,000 deaths in a war egged on, in part, by the same regional rivals that are heading the diplomatic process, Syrians are understandably skeptical of a resolution. But sources close to the talks say there are at least two factors that have hastened the current push for peace: the Assad regime’s recent military defeats, which have exacerbated fears of Syrian state collapse, and the regional diplomatic breakthrough of the Iran nuclear deal.

Whereas six months ago Syrian officials were broadcasting brazen confidence that victory was around the corner, momentum has shifted decidedly in favor of the rebels — and not the “moderate” factions armed and trained by Washington. In May, a coalition of hardline factions led by the Nusra Front, Al-Qaeda's affiliate in Syria, captured the provincial capital of Idlib, and are now creeping ever closer to the coastal enclave that shelters Assad’s ruling sect, the Alawite minority. Faced with the specter of bloody reprisal should hardline rebels make inroads in regions like Latakia, Alawites and other regime supporters have staged rare protests in recent days, compounding domestic pressure on a regime that has sent tens of thousands of their men to die in battle.

More importantly, however, is that those same developments have stirred fears in Western and Gulf capitals, which pull the financial and political strings of the Syrian opposition. There, officials are said to be reevaluating their vehement insistence that Assad must go. Increasingly, analysts say, Western and even Gulf states fear that groups like Nusra Front and the Islamic State in Iraq and the Levant (ISIL) will fill the void if the regime falls. Despite allegations that the region’s Sunni-majority states, especially Turkey, have abetted hardline groups in Syria as a means of countering Assad, none of these countries wants to deal with the security liability and inevitable explosion of refugees that would result from a rebel takeover.

“At first, everybody could say the alternative to Assad was their own faction. The U.S. said it would be the moderates,” said Joshua Landis, a leading expert on Syria at the University of Oklahoma. “Today you can’t say those things. All the major winners on the ground today are Salafist-jihadists. That causes a real anxiety, especially now that Assad is looking weak.”

Publicly, neither side has shown a willingness to budge from its stance on whether Assad could ever be at the helm of a post-war government. The U.N. Security Council’s statement on Monday includes language about a transitional government with full executive powers chosen “on the basis of mutual consent” — as per the Geneva agreement — but no explicit declaration that Assad could not remain in office.

Tacitly, however, the Obama administration and, perhaps, its regional allies have shifted gears. “America has set destroying or containing ISIS as the core goal in the region. And our military leaders are trying to organize a foreign policy based on that goal,” Landis said, using another acronym for ISIL. “So our other goals — overturning Assad, creating democracy in Syria, power-sharing in Iraq — they’ve taken a second seat to destroying ISIS.”

At the same time, Landis said, “many American policymakers regret sweeping away the brutal dictatorships of the Middle East,” like Iraqi dictator Saddam Hussein and Libya's Muammar Qaddafi, whose downfalls created power vacuums that allowed hardline, anti-American factions like ISIL to metastasize. “That leads them to have this great ambivalence about Assad,” he said.

On the other side of the equation, some analysts have argued that Russia and Iran are increasingly open to cutting Assad loose if an arrangement could be reached that maintains their influence in Syria. Support for the regime has been costly — both financially and politically — and diplomats say Moscow, in particular, is anxious about the expansion of ISIL, which the Assad regime has been accused of colluding with in order to focus fire on their mutual enemies — the other rebel factions. ISIL is already operating franchises across the Muslim world and could enflame Russia’s low-burning Chechen insurgency, analysts say.

For Iran, the historic nuclear deal with the West may similarly shift its priorities, at least behind closed doors. Syria is “the most complex and important” of the proxy battles taking place across the region between Iran and the Sunni Gulf states, said Rami Khouri, a senior fellow with the Issam Fares Institute at the American University of Beirut, and it is therefore perhaps the hardest to solve. But there is mutual interest in preventing the chaotic stalemate from crossing more borders, creating more refugees, and — most of all — enabling ISIL to expand further.

"The best available option now is to seek an American-Iranian-Russian-Saudi agreement on basic principles to end the fighting,” wrote Khouri in an op-ed for Agence Global news agency. That three of those four “met this week to discuss options for winding down the war in Syria is as strong a sign as we are likely to get that all key parties now seriously seek a political solution to ending the war(s) in Syria.”

But some analysts say things may be headed away from a unified transitional government to rule Syria and towards a territorial compromise, whereby Assad maintains control of his “rump state” that stretches from Damascus up along the Western coast to Latakia. Iran and Russia would therefore maintain influence in part of the country, while various Sunni and Kurdish factions hold sway elsewhere. Cementing these divisions might be the most viable model for achieving a cease-fire, Landis said. “Assad is incapable of reform. But he is capable of shrinking his state, which he’s done quite successfully over the past few years.”