In the first week of October, King Salman bin Abdulaziz al-Saud visited Moscow for talks with Russia’s President Vladimir Putin, supporter of Syria’s President Bashar al-Assad, whom the kingdom wants deposed.

It has since emerged that Saudi Arabia is entertaining the possibility of China directly investing in Saudi Aramco. This might shatter hopes it has cultivated that there would be a lucrative international initial public offering (IPO) for shares in the world’s leading oil producer.

It is less than six months since US President Donald Trump visited Riyadh to seal a new relationship and bury his predecessor’s ambivalent approach to the kingdom. In September, Crown Prince Mohammed bin Salman signed a defence agreement with the UK three days after Qatar announced it was to buy fighter aircraft from BAE Systems. It was as if Riyadh and its Arab partners had not declared an embargo on Qatar.

Saudi Arabia has been reaching out to Iraq, which is heavily influenced by Iran, the kingdom’s principal regional rival.

On 13 October, Riyadh reaffirmed its support for a two-state solution to the Arab-Israeli conflict. It is regularly reported that Saudi Arabia’s contacts with Tel Aviv are growing.

At home, women will be able to drive for the first time in the kingdom’s history next summer. The religious police are being restrained. But there are complaints that even the limited political dissent allowed by the late King Abdullah bin Abdulaziz is no longer tolerated.

Riyadh has revised its vaunted National Transformation Programme, leaving businesses wondering what the kingdom’s long-term economic objectives are.

Saudi Arabia’s recent policies appear to be a mass of inconsistencies. But they make sense, nevertheless. Riyadh is often accused of pursuing an ideological agenda shaped by a puritanical form of Islam. The reality is that it is one of the Middle East’s most pragmatic. Before oil transformed Arabia, Saudi rulers did not have the luxury of placing ideology above the practical realities of daily life in one of the most hostile environments on earth. Survival in the Middle East’s unstable political environment and an increasingly multipolar world continues to be the overarching priority.

The US’ unpredictable foreign policy, Russia’s Middle East opportunism, the EU’s pusillanimity, Israel’s stubbornness, Iran’s hostility and the disintegration of states on the kingdom’s borders present existential challenges. But they are also creating opportunities for a government with the capacity to think and act flexibly.

Riyadh looks like it is making it up as it goes along. In many respects, it is and always has.