President Obama flew to Saudi Arabia to patch up relations with King Abdullah at the end of last week in his first visit in five years. The alliance had been strained by Saudi anger over US negotiations with Iran on its nuclear programme and Obama’s refusal to go to war in Syria to overthrow Bashar al-Assad last year. For its part, the US is upset by Saudi Arabia covertly supporting al-Qa’ida-type movements in Syria and elsewhere.

The US-Saudi relationship is a peculiar one in that it is between a reactionary theocratic monarchy – it is the only place in the world where women are not allowed to drive – and a republic that claims to be the chief exponent of secular democracy. The linkage is so solid that it was scarcely affected by 9/11, though al-Qa’ida and the hijackers had demonstrably close connections to Saudi Arabia.

The Saudis want to persuade the US to make a greater effort to overthrow Assad in Syria. Saudi Crown Prince Salman bin Abdulaziz told the Arab League in Kuwait last week that “the legitimate Syrian resistance has been betrayed by the international community and left easy prey to tyrant forces”. This is a bit rich, coming from the potential ruler of a state in which every expression of dissent is being crushed, and the number of political prisoners could be as high as 30,000. Minor criticism of the state on Twitter is enough for Saudis to be called in by the security services.

On 3 February, King Abdullah promulgated a decree that made Saudi jihadis fighting abroad liable to 20 years in prison on their return. The idea is to choke off the supply of Saudi recruits volunteering to fight in Syria, said to number 2,500 at present. Previously, Saudis were able to reach Syria with ease, a sign that the government was turning a blind eye, but now it is saying it will jail them if they come back.

The U-turn may not work: fighting in Syria has popular support in Saudi Arabia; Wahhabism, a puritanical and intolerant variant of Islam, is the ideology of the Saudi state which regards Shia and Sufi Muslims as heretics little different from Christians and Jews. Having stoked hostility to Iran and Shia Islam for so long, the government may not find it easy to demonise and punish Saudis who fought against them.

The criminalisation of the jihadis is designed in part to persuade the Americans that Saudi Arabia is not encouraging Jabhat al-Nusra and the Islamic State of Iraq and the Levant (Isis), both al-Qa’ida-type groups, to take over northern Syria and western Iraq. On the contrary, the Saudis say they want to fund and supply a third military force in Syria that will fight both President Assad and the anti-Assad jihadi forces.

Given that the Syrian army is on the offensive in and around Damascus, Homs and Aleppo, any Saudi and American backed “third force” operating from Jordan is not going to turn the tide on the battlefield in the foreseeable future. If the Americans go along with this plan, then they are saying, in effect, that they are prepared to conduct a long proxy war in Syria, contrary to all the hypocritical outpourings in Washington and Riyadh about ending the suffering of the Syrian people.

For its part, the US establishment has never taken on board that, when it backed the anti-Assad rebels in Syria, it automatically destabilised Iraq. This is sometimes attributed to the departure of US troops, but it was inevitable that an uprising centred on the Sunni majority in Syria, would energise and radicalise the Sunni minority next door in Iraq. Three years after the protests started in Syria, the whole Euphrates valley from, to Jarabulus, on Syria’s border with Turkey, is in the hand of Isis and Jabhat al-Nusra. In the past week, Jabhat al-Nusra fighters have for the first time broken through to the Mediterranean coast north of Latakia.

A problem for the Saudi government is that it has always used jihadis as an arm of its foreign policy, believing that it could disclaim responsibility for their actions. Private donors and jihadi preachers were allowed to operate unhindered. But the disadvantage of this hands-off approach is that, in Afghanistan, Pakistan, Syria and Iraq, the jihadis were not under total Saudi government control. Those battling in Syria and Iraq today will not be pleased to learn that Riyadh has decided that they have suddenly become outcasts. In recent months, jihadi websites and messages on Twitter have begun to attack the Saudi royal family, one showing a picture of King Abdullah giving a medal to George W Bush with the caption: “medal for invading two Islamic countries”. Another shows trucks packed with armed gunmen with a caption saying they are heading for northern Saudi Arabia.

The Saudi government is showing signs of nervousness. It has backed a counter-revolutionary wave across the Middle East that, in many places, has succeeded. Democratic protesters in Bahrain were crushed in a Saudi-backed clampdown in 2011. In Egypt, it is financially supporting the military regime that overthrew the democratically elected President Morsi in 2013. In Syria, it has ensured that the political opposition is dominated by Islamists and is funded and largely directed by itself.

But, along the way, the Saudi royal family is making a lot of enemies. They range from members of the Muslim Brotherhood in the Gulf who find they are being targeted as “terrorists” despite being peaceful. There are jihadis in Syria who feel they were encouraged and then betrayed. Saudi liberals, who like the new anti-terror laws when applied to jihadis, find that innocuous tweets may land them in jail, and a mildly progressive publisher at the Riyadh International Book Fair this month had its display smashed up, probably by the religious police.

American, British and other foreign visitors to Saudi Arabia usually behave with fawning respect towards their hosts in the belief that it is in their national interest to do so. In the case of President Obama, there are $87bn (£52bn) in proposed US defence sales, including $29bn for F-15s and $31bn for helicopters, to consider. But the Obama visit has brought together a strange alliance in Congress of conservative Christian Republicans and liberal Democrats, 52 of whom signed a letter asking Obama to raise with King Abdullah and other officials the fact that “Saudi Arabian authorities have harassed, intimidated, and imprisoned almost all the country’s leading independent human rights activists”. It mentions Mohammad al-Qahtani and Abdullah al-Hamid, serving long sentences for setting up a local human rights organisation. The letter concludes that “the Government of Saudi Arabia must end its ban on public gatherings, lift restrictions on social media, stop the use of torture, and reform the new so-called ‘anti-terror’ laws that practically criminalise all forms of peaceful dissent”.

The Saudi royal family survived the 2011 uprisings without domestic upheaval. It has since gone a long way to restore the old status quo of authoritarian regimes in the Middle East, but the kingdom itself is becoming ever more divided and unstable.