On February 1, a military transport plane left a Russian airbase in Latakia, Syria, landed at an airfield near Egypt’s border with Libya, then returned to Syria. For months there had been unconfirmed reports that Cairo had sent forces to assist the Syrian regime in the country’s civil war and at first glance the flight appeared to have corroborated those suspicions. That now looks unlikely—the jet’s final destination was Russia, where it had reportedly brought wounded fighters, loyal to the Kremlin-allied Libyan strongman Khalifa Haftar, in for treatment. But the very fact that Cairo is coordinating with the Damascus-Moscow alliance on such an operation underscores one of the Middle East’s worst-kept secrets: Cairo supports the Syrian regime of Bashar al-Assad.

Back in November, Egyptian President Abdel Fattah el-Sisi essentially admitted as much. Cairo’s priority “is to support national armies, for example in Libya,” he told Portuguese state television. “The same with Syria and Iraq.” The host then pressed Sisi over whether he meant the Syrian regime. “Yes,” Sisi replied plainly.

It was the first time that Egypt, a longtime U.S. ally, openly acknowledged that it sides with the Syrian government. The Assad regime is not only allied with U.S. adversaries Iran and Russia but is also loathed across much of the Arab world for its scorched-earth attacks and the refugee crisis that its civil war has spawned. Sisi is now one of the only Arab leaders to explicitly back Damascus, which since late 2011 has been suspended from the Arab League and which Al Jazeera—by far the most watched television network in the Arab world—incessantly rails against.

Of course, hints of Sisi’s sympathy for his Syrian counterpart have been visible for years. Back in July 2013, just weeks after then-army chief Sisi led the military in removing Cairo’s Muslim Brotherhood-led government, Egypt and Syria agreed to revive diplomatic ties. (The Brotherhood regime had cut them to protest Damascus’ heavy-handed crackdown on dissent.) Since then, Egypt has followed a wait-and-see approach, biding its time to see who would emerge victorious in Syria before coming out strongly for or against one side. When, for example, Assad seemed on the defensive amid Islamic State (ISIS) advances in summer 2015, Sisi reportedly told visiting diplomats to begin preparations for his downfall.

Shortly thereafter, however, the tide turned. Russia’s intervention in Syria in September 2015 swung the momentum in the regime’s favor, and the Assad government began to appear, more than at any time since 2011, the likely victor. Sisi took notice, and by late last year, the previously unsayable—that Syria is better off with Assad than without him—ceased to be so.

In October 2016, shortly before the interview with the Portuguese press, Egypt—a rotating member of the UN Security Council—sided with Moscow in opposing a French-sponsored draft resolution calling for an immediate end to air strikes in Aleppo, where the Syrian regime and Russia have conducted a punishing campaign against the city. The same day, Egypt joined Russia (and China and Venezuela) in supporting an amended draft that removed all reference to the city. That same month, Syrian state media reported that Damascus had hosted bilateral meetings with high-level Egyptian officials, including the intelligence chief, and a Syrian army spokesman said that talks for joint-military operations were at “an advanced stage.”

Cairo’s pro-Assad tilt has drawn the wrath of its most important Arab ally and main financial backer, Saudi Arabia, which since Morsi’s overthrow has pumped more than $25 billion into Egypt’s ailing economy. In October, Riyadh called Cairo’s pro-Kremlin moves at the UN “painful,” and the prominent Saudi journalist Jamal Khashoggi tweeted a reminder that, as the sole Arab member of the Security Council, Egypt should act according to consensus Arab opinion. The next month, the Saudi oil giant Aramco announced that it would suspend oil supplies to Egypt until further notice.

Why, then, is Cairo cozying up to Assad at the risk of damaging its own regional prestige, and of irking its financial backers, when its own economy is in profound crisis?

First, Cairo’s threat perception differs from that of its Arab allies. Although Saudi Arabia views Assad’s patron, Iran, as the foremost threat to its security and interests, Egypt reserves that place for Sunni Islamists such as the Muslim Brotherhood and ISIS.

The Brotherhood has for decades been the Egyptian army’s primary adversary. Sisi himself came to power in 2013 by removing a Brotherhood regime that had run the country for just a year, and once in power he proceeded to imprison tens of thousands of the group’s members. Since then, in Egypt’s sparsely populated Sinai Peninsula, an ISIS affiliate has killed hundreds of Egyptian servicemen in an insurgency with no end in sight.

When Sisi looks at the Syrian conflict, he is reminded of the fragility of his own rule. In Syria, as in Egypt, a decades-old regime—the Assads have ruled Syria for four decades, and army officers in Egypt have for most of the last seven—is pitted against rebels that he dubs extremists. Although untangling the affiliations of Syria’s many opposition parties is tricky, at least one such grouping, the Istanbul-based Syrian National Council, is indeed, by most accounts, Brotherhood-dominated. As for ISIS, it has distinguished itself as one of the most brutal and effective fighting forces arrayed against Assad.

Second, Cairo and Damascus are in lockstep over their antipathy for the government of Turkish President Recep Tayyip Erdogan, which is itself rooted in political Islam. Since the 2013 coup, Erdogan has been the chief antagonist of the Sisi regime, hosting Brotherhood leaders and beaming out Arabic-language TV stations that rail against the Egyptian leader’s “illegitimacy.” The Turkish president is even fond of flashing the Brotherhood’s signature four-finger salute. Ankara has similarly been the leading international opponent (along with the Saudis) of the Assad regime, providing logistical support to sundry opposition groups, and allowing them—as well as ISIS—to traverse its border with Syria largely unhindered.

Finally, Egypt’s closer ties with Assad are a function of its warming relations with Russia. Cairo’s frayed post-coup ties with the former administration of Barack Obama led it to turn to the Kremlin for everything from helicopters to joint military drills to nuclear power. Now, sensing an opening, Cairo is keen to cultivate relations with President Donald Trump, who has consistently urged closer cooperation with Moscow against extremists in Syria while opposing actions to bring down the Assad regime.

My own conversations with Egyptians during a recent visit suggest that many tacitly or explicitly support Sisi’s overtures to Assad. True, there was a time, in the early stages of the Syrian uprising, that Assad seemed destined to go the way of Hosni Mubarak, the longtime Egyptian leader forced to resign in early 2011 after 18 days of popular protests. Back then, a critical mass of Egyptians would likely have welcomed Assad’s ouster as part of the wave of revolutions optimistically called the Arab Spring.

But the Middle East of 2017 is dramatically different from that of six years ago. Mubarak’s removal led to the unhappy experience of life under the Brotherhood, and the subsequent bloody power struggles between the Islamist group and the army. Syrians, like Libyans and Yemenis, rose up against despots only to reap chaos and carnage instead. Revolution fatigue has set in in Egypt, along with a certain reluctant consensus in favor of stability even at the cost of democratic freedoms.

The coming year promises to be full of surprises, not least in the Middle East, where long-standing partnerships are now coming into question while unlikely ones form in parallel or in their place. One such surprise is likely to be ever-closer ties between Cairo and Damascus: one of them a decades-long U.S. ally and the other an anti-American strongman in league with the Kremlin and Tehran.