IN JANUARY this year Muhammad bin Salman, the young deputy crown prince who in effect runs Saudi Arabia, declared an end to his country’s “comatose” foreign policy and a determination to push back against Iran. The Syrian rebels he supported looked unbeatable in Aleppo. His generals spoke of the imminent capture of Sana’a, Yemen’s capital, from the Houthi rebels who had seized it. He kept Iran and its client militia, Hizbullah, from imposing their choice of president in Lebanon. Officials spoke of bankrupting Iran by saturating the market with oil, regardless of the wishes of OPEC partners. A Saudi ambassador even went back to Baghdad, for the first time in 25 years.

But at the end of the year the kingdom finds itself in retreat on all fronts. Its ambassador has pulled out of Iraq, fleeing a torrent of abuse from Shia politicians who look towards Iran. Pounded by Iranian, Russian and Syrian government forces, the rebels in Aleppo are on the verge of defeat. The Saudis have bowed to Iran’s preference for Lebanon’s president. And at an OPEC meeting on November 30th, they agreed to shoulder the largest share of a production cut in a bid to restore prices, while letting Iran raise its production to pre-sanctions levels.

In Yemen, Saudi Arabia’s Houthi foes seem bent on denying Prince Muhammad a dignified exit, launching repeated cross-border raids and last week declaring their own new government, rather than agreeing to form one including the exiled president as the prince wants. “Yemen will be Saudi Arabia’s Vietnam,” says a contemptuous Iranian official. “It is bleeding the Saudis’ military and diplomatic prestige.” If Saudi Arabia agrees to leave the rest of the region, he says, Iran will let it keep Bahrain, the little island state linked by a causeway to Saudi’s eastern coast.

This reversal of fortune owes much to the successes of Iran’s military support for the Arab world’s Shia and allied forces—Syria’s President Bashar al-Assad, Iraq’s army and paramilitary forces, and Lebanon’s militia-cum-political party, Hizbullah. “They are surrounding us with militias,” protests General Ahmad Asiri, who advises the deputy crown prince on the Yemen campaign. But Saudi Arabia is also losing soft power, cutting its funding to traditional Sunni allies, who have begun looking elsewhere. With his construction firm in Saudi Arabia in trouble because of government cuts, Saad Hariri, who heads Lebanon’s Sunni bloc, has accepted the post of prime minister under Hizbullah’s choice for president. Egypt’s President, Abdel-Fattah al-Sisi, is making overtures to Syria, Russia and even Iran after Saudi Arabia cut back shipments of free oil.

As relations fray in the broader region, the prince is trying to strengthen ties with the principalities in his back yard. King Salman, his father, made a rare foreign trip to four Gulf states in early December. A summit in Bahrain’s capital, Manama, which ended on December 7th, aimed to advance plans to turn the Gulf Cooperation Council into a Gulf Union with tighter defence co-ordination. But there, too, not all are convinced. “There’s a latent fear of Saudi hegemony,” says Becca Wasser, who monitors the Gulf for RAND Corporation, an American think-tank. Oman, in particular, prefers to be semi-detached.

Still, the OPEC agreement defied expectations, indicating that both Iran and Saudi Arabia can prioritise economics over regional confrontation. Both are failing to cover domestic spending, let alone foreign adventures. Iran’s government needs oil at $55 per barrel to break even, says the IMF; Saudi Arabia’s needs $80. “The oil producers can’t sustain the external and proxy wars they once could when oil was a $120 a barrel,” says a former World Bank economist in Beirut. “They realise they need to change.” Greater stability and more open borders, too, says an Iranian official, would help Iran find new markets for other exports, such as of cars and cement.

The coming of Donald Trump in America is a further reason for restraint. “Both countries are playing a waiting game,” says Adnan Tabatabai, the head of CARPO, a Bonn-based think-tank which is running “track 2” (non-official) talks between Saudis and Iranians. Both fear Mr Trump’s reputation for impulsive action—even a senior Saudi prince has urged him not to break off the global deal that has limited Iran’s nuclear programme. Both sides seem uncertain whether he will tighten sanctions on Iran or ratchet up JASTA, the new law that allows Americans to sue Saudi Arabia for losses on September 11th 2001. Above all, and despite the influence of hardliners in both camps, neither side wants anything resembling a direct war.

But tensions are not abating; quite the reverse. Saudi Arabia severed diplomatic relations with Iran in January because of an attack on its embassy in Tehran that followed the execution of a prominent Shia cleric and three other Shias. This week came the news that 15 more Shias have been sentenced to death in Saudi Arabia on charges of spying for Iran.