Remember how we got here. Three months ago, the US, Britain and France were poised to launch yet another attack on an Arab and Muslim country, this time war-wracked Syria. An unexpected, and unprecedented, vote by British MPs halted the bid to escalate the war. That stiffened resistance in the US Congress.

As Obama struggled to win support, Russia seized the chance to press for the UN-supervised destruction of Syria's chemical weapons. A deal was reached and the threat of attack abandoned. A couple of months on and Iran, Syria's closest ally, has now signed an agreement with the big powers to limit its nuclear programme in exchange for sanctions relief – and Syrian peace talks are back on the agenda for the new year.

The west's August attempt to confront the Iranian-Syrian "axis of resistance" has been turned on its head. Russia has been bolstered without lifting a finger. The closest US allies in the Middle East, Israel and Saudi Arabia, are crying betrayal and demanding their supporters sabotage the deal in Congress.

In fact, both agreements simply reflect a recognition of reality after 12 years of failed wars of intervention across the Middle East. In the case of Syria, despite covert intervention by western and Gulf states, the Assad regime has been gaining ground as the rebel camp slips further into the grip of al-Qaida-linked sectarian jihadists.

When it comes to Iran, the Shia Islamic republic has been hugely strengthened by the west's war on terror and the US-British invasion of Iraq in particular. Sure, Iran has been hurt by sanctions imposed by nuclear-armed states and the campaign of assassinations and sabotage waged by the US and Israel.

But the restrictions on its uranium enrichment programme agreed in Geneva on Sunday are significantly less onerous than those Iran offered in 2005, when its proposal of a centrifuge cap of 5,000 was rejected by the US out of hand. It now has upwards of 16,000.

What has changed is that the costs of confrontation with Iran have escalated for the US; the credibility of an all-out attack on Tehran is now vanishingly small; the west's Arab allies are in turmoil or immersed in an unwinnable regional sectarian war – and Iran holds a key to conflicts the US wants defused or settled, from Palestine to Afghanistan.

Whether the nuclear agreement lasts or goes further, Geneva is a measure of realism in a region turned upside down by increasingly bizarre alliances. Take Israel, the secular Jewish state, and Saudi Arabia, the Sunni sectarian autocracy. They are now not only working hand in glove against Iran, but both strongly backed the abortive attack on Syria and championed July's military coup against the elected Islamist president in Egypt.

The US-backed theocratic Saudi dictatorship, along with the UAE, Jordan and Israel, are now in close alliance with the secular military regime in Cairo – which is busy buying weapons from Syria's ally Russia – while Saudi Arabia and other Gulf states are the main backers of Islamist and jihadist rebel forces in Syria. In fact, the Saudi authorities have been offering to release their own jihadist prisoners if they agree to go and fight in Syria and Lebanon with al-Qaida-linked groups such as the Islamic State in Iraq and Syria. Meanwhile, Islamist Turkey, which also backs the Syrian rebels, is trying to move closer to Iran.

The chaos and cross-currents are a product of the war on terror and the Arab uprisings that flowed out of it nearly three years ago. The campaign that began in Afghanistan, and passed through the destruction of Iraq via drone wars against the terror groups it fuelled, reached its last phase in the attempts to hijack or crush the popular revolts across the Arab world.

At every point, the war has failed in its stated aim of fighting terror and left a trail of destruction, death and sectarian conflict in its wake, from Pakistan to Libya. It has also revealed the limits, rather than the extent of US and western power to impose its will by military force. And it's that strategic defeat and overreach – paid for at such great human cost – that has been reflected in the deals made with Iran and Syria this autumn.

The US administration has now signalled it wants a more modest engagement in the Middle East, focused on Iran, Syria and the Israel-Palestine conflict, as it "pivots" towards Asia and the rising power of China. "We've got interests and opportunities in that whole world," as Obama's national security adviser, Susan Rice, puts it. That's been interpreted by some as the prelude to a US withdrawal from the most directly western-dominated region in the world, encouraged by declining US dependence on Middle East oil.

That would be too much to hope for. The US has been boosting its military presence and archipelago of bases in the Gulf, and the Middle East will continue to be crucial to the global energy market. But the failure of the war on terror and US decline means it is likely to try to use a reduction of tension with Iran to streamline and scale back its military involvement.

Which would, of course, be welcome for the people of a region trying to carve out their own future. The west's baleful terror war will carry on across the Arab and Muslim world in the form of drone attacks and special forces operations. But the appetite for full-scale air and land campaigns seems to have exhausted itself. That can only be good for all of us.

Twitter: @SeumasMilne