In a pre-dawn raid on Monday, militants attacked a Saudi border post from the Iraqi side of the frontier. The resulting clash left three soldiers and four militants dead, according to the Saudi government news agency.

It later emerged that one of the dead soldiers was no ordinary border guard but the commander of Saudi Arabia’s northern border forces, Brigadier General Awdah al-Balawi. This suggests that the attack, far from being random or opportunistic, had been carefully targeted and perhaps based on inside information regarding the general’s whereabouts.

The attack has been widely attributed to Islamic State, with some reports saying the rebel group has now claimed responsibility for it. This might be viewed simply as a reprisal for Saudi participation in the US-led bombing campaign against Isis, but Isis has also been seeking to extend the current conflict in Syria and Iraq into Saudi territory.

There is no doubt that Isis has both sympathisers and active supporters inside the kingdom – it claimed responsibility for shooting a Danish citizen in Riyadh last November, for example – but whether it will be able to establish a military foothold is another question. Isis tends to flourish militarily in places where central government is weak, but that is not the case in Saudi Arabia.

In military terms, the Saudi security apparatus is probably capable of suppressing Isis on its own territory, just as it did with al-Qaeda a decade or so ago, but it is in no position to confront Isis at the ideological level. The problem here is that Isis and the Saudis’ Islamic kingdom are ideologically similar, so attempts to challenge Isis on ideological grounds risk undermining the Saudi state too. As Heba Saleh and Simeon Kerr noted in the Financial Times last September:

“Some of the features of Isis ideology, such as its hatred of Shia Muslims and application of strict punishments such as limb amputations, are shared with the purist Salafi thought that defines Saudi Wahhabism. Isis has explicitly referenced early Wahhabi teachers, such as Mohammed ibn Abdulwahhab, to justify its destruction of Shia shrines and Christian churches as it cuts a swath through Iraq and Syria. Thousands of Saudi nationals have been recruited to its ranks.

“Yet, in contrast to the tacit official encouragement of more liberal voices after 9/11, any debate within Saudi Arabia over the role of its official creed in fostering the group’s extremism has been timid and largely confined to social media ...

“The Saudi authorities have been quick to condemn Isis. But, according to observers, they are anxious to avoid a potentially destabilising examination of common ideological links between the extremist group and the Saudi religious school whose support underpins the legitimacy of the royal family.”

The underlying issue, therefore, is the rival claims of king and would-be caliph. In the words of two Saudi government supporters: “To restore the ‘caliphate’, [Isis] would ultimately need to implant itself at the epicentre of Islamic life, the two holy mosques in Mecca and Medina. Therefore, [Isis’s] road to the caliphate runs through the kingdom of Saudi Arabia.”

Inconveniently for the Saudi monarchy, this challenge from the upstart caliph comes at a time of uncertainty over the royal succession. King Abdullah, now in his 90s, is in hospital – reportedly being treated for pneumonia – and his likely successor, Crown Prince Salman, is thought to be 77 and not in good health.

So far, Saudi efforts to confront Isis ideologically have mainly taken the form of denunciations from tame clerics – figures who have no prospect of influencing Isis supporters and sympathisers – but it is difficult to see what else they might do without calling their own state system into question.

The king and his princes have dug a hole for themselves by harnessing religion in the pursuit of power. Religious credentials bolstered their claim to legitimacy and helped them assert their authority. For a long time, those credentials served them well, but now they are becoming a liability and it may be too late to unfasten the harness.