The victims of the war in recent years are mostly Shia. Last week a suicide bomber walked into a snooker club in a Shia district of Quetta in Pakistan and blew himself up. Rescue workers and police were then caught by the blast from a car bomb that exploded 10 minutes later. In all, 82 people were killed and 121 injured. “It was like doomsday,” said a policeman. “There were bodies everywhere.”

Responsibility for the bombing was claimed by the banned Lashkar-e-Jhangvi, a Sunni fundamentalist group behind many such attacks that killed 400 Shia in Pakistan last year.

The dead in Quetta come from the Shia Hazara community, many of whom migrated from Afghanistan in the last century. “They live in a state of siege,” says Ali Dayan Hasan, of Human Rights Watch. “Stepping out of the ghetto means risking death. Everyone has failed them – the security forces, the government, the judiciary.” In this they are little different from the 30 million Shia in Pakistan who are increasingly beleaguered and afraid in the midst of a rising tide of anti-Shia sectarianism.

The atrocity in Quetta will soon be forgotten outside the area ,but the victims were not the only Shia community to come under attack last week. In Bahrain, where the Shia majority is ruled by the Sunni al-Khalifa royal family, the high court confirmed prison sentences – including eight life sentences – on 20 activists who took part in the pro-democracy protests in 2011. This happened even though the original sentences were passed by military courts using evidence extracted by torture.

The sectarian nature of what is happening in Bahrain has never been in doubt. At the height of the crackdown the Bahraini security forces bulldozed 35 Shia mosques, husseiniyas (religious meeting houses) and holy places. The authorities claimed that they were inspired by a sudden enthusiasm to enforce building regulations despite the political turmoil.

Sunni-Shia friction has a long history but took its most vicious form after the overthrow of the Shah by Ayatollah Khomeini in 1979 and the creation of a revolutionary theocratic Shia state in Iran. The Iran-Iraq war of 1980-88 appeared to end Iranian hopes of spreading the revolution to its neighbour, but after the US invasion of 2003 – to the dismay of the White House and to the horror of Saudi Arabia – Iraq became a Shia-run state. “We are the first Arab state to be controlled by the Shia since the Fatimids ran Egypt 800 years ago,” one Iraqi Shia activist exulted to me at the time.

As a result of the Sunni-Shia civil war in Iraq in 2006-07, Baghdad became an overwhelmingly Shia city. The Sunni in the capital increasingly lived in ghettos. The government, army, police and judiciary came under Shia control. Across the Middle East, the Shia appeared to be on a roll, exemplified by Hezbollah’s success in withstanding the Israeli attack on Lebanon in 2006. In Afghanistan the traditionally down-trodden Shia Hazara community flourished after of the defeat of the Taliban. However, the overall extent of the Shia success was exaggerated: in most Muslim countries the Shia form a vulnerable minority. In the last two years the Shia revolution has been succeeded by a Sunni counter-offensive. The Shia democratic uprising was crushed in Bahrain, and Hezbollah wonders how it will fare if, in future, it faces a hostile Sunni government in Damascus. Until a few months ago the sectarian and ethnic balance of power in Iraq looked stable, but prophecies of a Sunni takeover in Syria are having destabilising consequences.

The uprising in Syria is not so far wholly sectarian, but is on its way to becoming so. Shia and Alawite villagers flee as the rebel Free Syrian Army moves in. A video posted on YouTube shows rebels ransacking and burning a Shia husseiniya outside Idlib in north-west Syria.

All this leaves the US and its Western allies with new dilemmas. In 2003 the US found that in Iraq it had opened the door to Iran by overthrowing Saddam Hussein. Its solution was to try to keep power itself in Iraq through an old-fashioned occupation, but this failed disastrously. From 2007 it adopted a new strategy known by some in the White House as the “redirection”, making US policy more militantly anti-Iranian and pro-Saudi and, therefore, inevitably more pro-Sunni and anti-Shia.

In a revelatory piece in the New Yorker in 2007, Seymour Hersh described how this “redirection” has moved “the United States closer to an open confrontation with Iran, and, in parts of the region, propelled it into a widening sectarian conflict between Shia and Sunni Muslims”. Iran, strengthened by the outcome of the US invasion of Iraq, was demonised as a greater threat than the Sunni radicals. Its allies, Hezbollah and Syria, were targeted for clandestine operations. Hersh says “a by-product of these activities has been the bolstering of Sunni extremist groups that espouse a militant vision of Islam and are hostile to America and sympathetic to al-Qa’ida.”

In fact the main al-Qa’ida franchises in Iraq and Pakistan have always been more enthusiastic about killing Shia than killing Americans. The success of the Arab Spring movements was in part owing to the new willingness of Washington to tolerate the Muslim Brotherhood taking power, judging that this would not open the door to jihadis seeking to wage holy war.

The logic of the US policy of covertly co-operating with fundamentalist Sunni groups has reached its logical conclusion. There is now “good” al-Qa’ida on our side and “bad” al-Qa’ida fighting on theirs. In Syria, the former operates under the name of the al-Nusra Front, labelled by the US as the Syrian branch al-Qa’ida, and is the main fighting force of the rebel National Coalition. This is recognised by the US, Britain and many others as the legitimate representative of the Syrian people.

Meanwhile, in Mali an advance last week by the forces of the local al-Qa’ida franchise, of whom we don’t approve, led to immediate action by the French army and air force against them. The hypocrisy of it all is baffling.

PATRICK COCKBURN is the author of “Muqtada: Muqtada Al-Sadr, the Shia Revival, and the Struggle for Iraq.