In the course of 1979, three events changed the Middle East. The first was Iran’s Islamic revolution. That saw the overthrow of the shah, the autocratic, modernising ally of the west, by Ayatollah Khomeini. The second was the attack, led by a Saudi Arabian fundamentalist, on the Grand Mosque of Mecca, the heart of the Muslim world. The third, further afield but equally important, was the Soviet invasion of Afghanistan.

The three were separate but the combination proved disastrous: the shah’s demise was supported initially by leftists as well but those who wanted to see a theocratic Shia state quickly gained the upper hand. The Mecca assault was mounted by extremists who saw the Al Saud dynasty as traitors to the strictures of Wahhabi Islam. Afghanistan became the first battleground for transnational jihad in modern times.

Forty years on, Kim Ghattas has not only drawn the big picture of how those events shaped the region but offers timely and thought-provoking insights into their continuing destructive influence. The weaponisation of sectarianism, women’s rights, the frustrated hopes of the Arab spring, the rise of Al-Qaida and Islamic State are all richly contextualised and illustrated.

Black Wave deals not only with rivals Iran and Saudi Arabia, but also Iraq, Pakistan, Afghanistan, Lebanon and Egypt. The Israel-Palestine conflict, too often placed at the centre of Middle Eastern geopolitics, plays only a supporting role. US foreign policy is presented as secondary to trends, ambitions and decisions in Tehran, Riyadh and Cairo. It avoids Orientalist tropes and accords agency, not just victimhood, to Arabs and Muslims.

Ghattas spent a successful career as a journalist for the BBC. It shows in her wonderfully readable account. Intellectuals, clerics and novelists are highlighted because they represent ideas and suffering in the face of repressive regimes and intolerant ideologies. The contrast with many academic studies of these countries and issues is striking – and very much in the author’s favour.

The story begins in Lebanon in 1977 when her home country was in the throes of civil war. Iranian exiles such as Imam Musa Sadr bonded with local Shia activists who recorded cassettes calling for the shah to go. Egypt’s president, Anwar Sadat, then stunned the world by flying to Jerusalem to offer unconditional peace to Israel. Following Khomeini’s triumphant return to Tehran, the PLO’s Yasser Arafat was his first VIP visitor.

Ayatollah Khomeini arrives in Iran in February 1979 after 15 years of exile. Photograph: Bettmann Archive

The Saudis were appalled by Iran’s revolution before the seizure of the Mecca mosque a few months later. But both events triggered a less visible but oppressive change – “a slow but forceful expansion of Salafist puritanism” that wasaccelerated by the Soviet move into Afghanistan and Saddam Hussein’s invasion of Iran in 1980. That was the start of an eight-year war that both sides narrated as Arabs versus Persians, employing divisive language dating back to the seventh century.

Ghattas has an enviable gift for going beyond politics. Arabic dialects, the music of the Egyptian diva Umm Kulthum, Beirut restaurants serving caviar during ceasefires and witty anecdotes about Hezbollah all serve as a backdrop. Peshawar in Pakistan became a mini-Arabistan thanks to the Saudi-financed (and US-backed) mujahideen in Afghanistan, while Baalbek in Lebanon was an outpost of Tehran.

Obfuscation and the feigning of ignorance would become favourite forms of Saudi subterfuge to evade responsibility

Another big theme is the exploitation of Islam by dictators. In the 1970s, 30% of Egyptian women wore the headscarf; by the mid-1990s, under Hosni Mubarak, that had risen to 65%. Migrant workers returned from Saudi Arabia to Pakistan and Syria to build mosques to show off their newfound wealth and piety. By 2003, in the wake of 9/11 and Saddam’s overthrow, Iraq was fertile ground for a Sunni insurgency.

Syria’s dark chapter of the Arab spring found it caught between Isis and the Iranian Revolutionary Guard Corps, backing Bashar al-Assad. Qassem Suleimani, commander of its elite Quds (Jerusalem) force, was the public face of Tehran’s growing influence – fuelling Saudi animosity from Iraq to Yemen – until he was assassinated by a US drone in Baghdad. Ghattas quotes Suleimani explaining how a gruesome incident involving an IRGC officer beheaded by Isis in Syria was divinely inspired. The officer’s widow declared “her husband had lost his head so the women of Iran could keep covering theirs”.

Her final chapter focuses on Jamal Khashoggi, the Saudi journalist who was murdered in his country’s consulate in Istanbul. Khashoggi’s life and horrific death embody large elements of this story – from early support for the Afghan mujahideen to his later, fatal realisation that the reforms of Crown Prince Mohammed bin Salman were designed, above all else, to maintain his dynasty in power. “Obfuscation and the feigning of ignorance would become favourite forms of Saudi subterfuge to evade responsibility for any violence or intolerance connected to the kingdom,” as the author wrote – before five hitmen were sentenced to death by a Riyadh court while those who issued their orders never faced trial.

Iran and Saudi Arabia took steps to ease tensions during the rule of the reformist President Khatami and the easier-going King Abdullah – and there are signs they may be doing so again since Iran’s devastating attack last September on the Aramco oil refinery at Abqaiq – for which the ever-unpredictable Twitterer-in-chief in the White House conspicuously failed to retaliate despite his policy of “maximum pressure” on Tehran. Whatever happens next in this long-running, oppressive and dangerous Middle Eastern drama, Black Wave will be a vivid, indispensable guide to the story so far.

Ian Black, the Guardian’s former Middle East editor, is a visiting senior fellow at the Middle East Centre, LSE

• Black Wave: Saudi Arabia, Iran and the Rivalry That Unravelled the Middle East by Kim Ghattas is published by Headline (£20)