RIYADH Saudi Arabia's execution of four prominent Shi'ites and dozens of al Qaeda figures appears to have been based on a calculation that the kingdom could crush support for Sunni jihadists without alienating more moderate Sunnis.
Riyadh knew its execution of Nimr al-Nimr and three other Shi'ites for involvement in police deaths would prompt protests abroad, but seemed to calculate that, within the kingdom at least, the consequences would be controllable.
By killing the four Shi'ites, Saudi Arabia was telling its Sunni majority it was still on their side. By also executing the 43 al Qaeda figures, Riyadh was sending a message that it intends to destroy any support for their militant Sunni cause.
The kingdom's severing of ties with Iran on Sunday -- after demonstrators stormed its embassy in Tehran in protest at the execution of Nimr -- also underlined an assertive new foreign policy to counter Tehran under King Salman's year-old monarchy.
Riyadh is relying less on the U.S. security umbrella, convinced it has to compensate for the perceived disengagement of a U.S. administration unwilling to do the heavy lifting on Middle East security.
"Enough is enough. Again and again Tehran has thumbed its nose at the West. They continue to sponsor terrorism and launch ballistic missiles and no one is doing anything about it," said a source familiar with the Saudi government's thinking who spoke on condition of anonymity.
The execution on Saturday of the 43 Sunni jihadists followed a series of bombings and shootings in which more than 50 Saudis have been killed since late 2014.
Awadh al-Qirni, a prominent Sunni cleric who backs the government against the jihadists, tweeted that the executions were "a message to the world and to criminals that there will be no snuffing out of our principles and no complacency in our security".
The Al Saud ruling family regard the expansion of Shi'ite Iran's influence in the Middle East as a threat to their security and to their ambition of playing the leading role among Arab states.
Inside the kingdom, however, it is the threat of a rebellion by the majority Sunnis that most alarms a dynasty whose rule is based on conservative support at home and an alliance with the West.
All past threats to the Al Saud, dating back to the 1920s, have been caused by conservative Sunni anger at modernisation or ties with the West.
That was why the al Qaeda uprising that began in 2003, and attacked the Al Saud by turning its own conservative Salafi brand of Sunni Islam against it, was such a danger. It is why the jihadist movement's latest iteration, Islamic State, is also a problem.
While Islamic State seems to lack real support among Saudis, some may sympathise with its broader goals, approving of its rhetoric against Shi'ites and the West and its criticism of corruption among the Al Saud.
The notion that Saudi Arabia believes it is facing not only a physical threat, but an ideological battle with a rival interpretation of Salafi Islam, was strengthened by state media's focus on Faris al-Shuwail al-Zahrani among the executed.
Zahrani, bearded, bespectacled, and in prison since 2004, is portrayed in Saudi media as al Qaeda's main ideologue during a series of attacks on expatriate housing compounds, police stations and oil facilities that killed hundreds.
Described at the time by the government as "one of the heads of strife, a preacher of takfir", Zahrani helped articulate the jihadist view that the Al Saud had abandoned Islam, and that it was the duty of Muslims to kill them and their allies.
Takfir, the process of excommunicating other Muslims by calling them infidels, is a pillar of Salafi Islam. But unlike in Saudi Arabia's Wahhabi version of Salafism, in which only state-appointed clergy may practise takfir, the jihadists say any Muslim can declare another to be infidel.
"The official view is that these people are extremists involved in a wanton excommunication of other Muslims, in disobedience to the rightful ruler and in 'sowing dissention and disorder in the land'. So they are beyond the pale of Sunni Islam," said Bernard Haykel, professor of Near Eastern Studies at Princeton.
The jihadists dispute Saudi Arabia's claim to lead Salafi Islam, the position of its state-appointed clergy as arbiters of religious orthodoxy, and the Al Saud's status as legitimate rulers of the country.
Official Saudi media presented the jihadist Zahrani and the Shi'ite Nimr as equivalents - "inciters of violence and terrorism" as Sunday newspapers described them.
It seemed to be an attempt by the government to reassure conservative Sunnis that Saturday's executions did not mean Riyadh would stop championing their sect against what it portrays as Shi'ite aggression across the Middle East.
(Additional reporting by Arshad Mohammed; Editing by William Maclean and Giles Elgood)