CAIRO – Egypt has made fighting Islamic militants its overriding foreign policy objective, a decision that has brought it closer to Syrian President Bashar Assad, Russia and Iran, in turn antagonizing its chief financial backer, Saudi Arabia.
The policy is risky at a time when Egypt is struggling to contain a homegrown Islamic insurgency and tackling its worst economic crisis in decades. Saudi Arabia, which has helped keep Egypt's economy from collapse with billions in aid, has already signaled its displeasure by holding back promised supplies of fuel.
This direction of Egyptian President Abdel-Fattah el-Sissi's foreign policy is rooted in the military's 2013 ouster of his predecessor Mohammed Morsi of the Muslim Brotherhood.
"Cairo's single-minded pursuit of the Brotherhood — and of any Islamist group that bears the slightest resemblance to the Brotherhood — has become the guiding principle of Egypt's foreign, as well as domestic, policy," Middle East expert Steven A. Cook wrote in Foreign Affairs magazine.
Perhaps no single incident showcased this direction as much as Egypt's support this month for a Russian resolution on Syria at the U.N. Security Council.
Moscow put forward its resolution even as it vetoed a rival French resolution calling for a halt to Russian and Syrian airstrikes, which have caused hundreds of deaths in the Syrian city of Aleppo in past weeks.
Egypt voted in favor of both drafts, saying it did so in hopes of stopping Aleppo's suffering. But siding with Russia — and by implication Assad — reflected the stance of el-Sissi's government that defeating Islamic militants in Syria is the priority.
It led to the first public spat between Cairo and Riyadh since el-Sissi took office in 2014.
Adding insult to injury, Egypt this week hosted one of Assad's top security aides for talks, while Russian and Egyptian commandos held joint war games — at a time of widespread outrage in the Arab world over Russia's air bombardment of Aleppo.
Saudi Arabia is seeking Assad's ouster and has strongly backed rebel factions, including ones with hard-line Islamist ideologies.
Egypt, in contrast, sees militants in Syria as a threat. It has been far cooler to the prospect of removing Assad.
Egypt's direction undermines Saudi Arabia's hopes to build a Sunni axis to block the influence of its top rival, Shiite, non-Arab Iran. In fact, Cairo's show of support for Assad put it closer to Iran, the Syrian leader's top ally.
Egypt has sided closer to Russia even though Moscow has banned commercial flights to Egypt ever since the downing a year ago of a Russian jet full of tourists in the Sinai Peninsula. The crash is blamed on a bomb placed onboard by Egypt's branch of the extremist Islamic State group.
The flight ban has been devastating to the tourism industry, which Egypt desperately needs to shore up its economy.
The campaign against Islamic militancy is integral to el-Sissi's claim to legitimacy, said Ayman al-Sayad, a prominent analyst.
El-Sissi took office in elections held a year after he led the military's 2013 ouster of Morsi, whose one-year in office sharply divided the country.
Security forces have since moved to crush the Brotherhood and other Islamists, killing hundreds and jailing thousands of others.
They have also been battling the IS-linked militant insurgency in Sinai, which grew stronger and deadlier after Morsi's ouster.
El-Sissi has repeatedly claimed that the Brotherhood's ideology is at the root of the world's troubles with militancy.
Cairo is willing to run the risks of its foreign policy in part because it believes "others similarly fear a takeover by political Islam," el-Sayad said.
But the Arab world's most populous country is also betting its backers won't end their support because "if it collapses, the fallout will be felt beyond its borders," he said. "It's true, but it involves an element of blackmail."
After the U.N. vote, the kingdom sharply rebuked Cairo. In an apparent response to this, el-Sissi said his government was pursuing "independent policies" aimed at safeguarding security in the Arab world "through an Egyptian perspective."
Cairo's willingness to antagonize the kingdom despite its economic reliance on the Sunni powerhouse has startled some.
"Egypt is going out of its way to flag its independent foreign policy," said Michael W. Hanna of the New York-based Century Foundation. "It's puzzling how the Egyptians expect this to work out."
Egypt and Saudi Arabia are also at odds over other issues.
Cairo decided not to send troops to Yemen as part of the Saudi-led coalition against Iranian-backed Shiite rebels. The move reflected its reluctance to be pulled back into a country where Egypt fought in an earlier bout of civil war in the 1960s.
It has also resisted being sucked into the sectarian rhetoric that defines the bitter Saudi-Iran rivalry and has kept up channels of communication with Yemen's Shiite rebels, Lebanon's Iranian- backed Hezbollah and the Shiite-led government in Iraq, another ally of Tehran.
El-Sissi's direct role in fighting militants has mainly been focused on the grueling battle against the insurgency centered in Sinai. But he has backed Libyan general Khalifa Hifter in a fight against militants in Egypt's oil-rich western neighbor.
He has also tightened Egypt's siege of the Gaza Strip, ruled by the militant Hamas group, shutting down most of the underground tunnels into Egypt that the 2 million Gazans depended on for essential goods.
Shady Lewis Boutros, a London-based Egyptian analyst, wrote this week in al-Modon, an online news site, that Egypt has succeeded in playing an effective, if limited, role in the region with a foreign policy that doesn't adhere too close to any side.
But that policy "also earns Egypt enmities that it can do without, especially when it desperately needs the support of some of them," he wrote.