Saudi Arabia's ruling Al Saud royal family are trying to adjust their relationship with the country's strict Wahhabi school of Sunni Islam as they increasingly view the teachings of some of its ultra-conservative clergy as a domestic security threat.
Radicalisation of Muslims in the world's top oil exporter has led to domestic attacks and the involvement of Saudi citizens in jihadist movements in Iraq and Syria, while extreme religious practices have damaged efforts to boost employment.
Over the past decade the House of Saud has not only put in place measures to control clerics and their sermons, but has started to favour more modern clergy for top state positions.
Saudi rulers are also starting to reform areas once the exclusive domain of the clergy, such as education and law, and have promoted elements of national identity that have no religious component.
Saudi Arabia remains one of the most religiously conservative countries on earth, and the royal family are not cutting off the clergy or ditching Wahhabism's basic precepts, analysts and diplomats say.
They are instead attempting to foster a reading of its teachings that distances it from Islamist militants such as Islamic State, and which better meets the demands of a modern economy.
"They've been pushing for a more national Wahhabism, one that is more modern in its outlook, one that is better in terms of the kingdom's image overseas, one that is more economically suitable," said Stephane Lacroix, author of Awakening Islam, a book about religious politics in Saudi Arabia.
Spokesmen for the government could not immediately be reached for comment.
Saudi Arabia's approach to religious doctrine is important because of its symbolic position as the birthplace of Islam, while its oil exports allow it to finance Wahhabi-oriented missionary activity abroad.
The Wahhabi clergy has been close to the Al Saud dynasty since the mid 18th century, offering it Islamic legitimacy in return for control over parts of the state and a lavish religious infrastructure of mosques and universities.
"The royal family's legitimacy is mostly based on Islam. Without this, the House of Saud is weak. But, politically, religion gives them the strong legitimacy," said Mohsen al-Awaji, a prominent Islamist activist.
Traditional Wahhabi doctrine is ultra-conservative, viewing Shi'ites as heretical, arguing against interaction with non-Muslims, opposing gender mixing, imposing a strict version of Islamic law and urging resumption of early Muslim practices.
Clerical control over education contributed to Islamist extremism among young Saudis, the royal family believe, which led to domestic security problems, and produced graduates with little grasp of subjects such as maths or foreign languages.
The senior clergy -- under pressure from King Abdullah -- have denounced militant Islamic doctrines, such as those of al Qaeda or Islamic State, but they still preach intolerant views.
They hinder efforts to reform the economy by arguing against women's employment, obstructing changes in the school curriculum to encourage technical subjects and blocking legal reform.
But the government now vets clerics in Saudi Arabia's 70,000 mosques, sacking many who disseminate extremism.
"Since 2005, since King Abdullah took power, he brought new ideas for the future," said Mohammed al-Zulfa, a liberal former member of the appointed Shoura Council, which advises the government.
Meanwhile, more modern-thinking clerics are being promoted and the top clerical council has been opened up to include scholars from the other main branches of Sunni jurisprudence beyond the Hanbali school followed by Wahhabis.
That council is dominated by older conservatives such as Saleh al-Fawzan and Saleh al-Luhaidan, who once called for Muslim media owners who broadcast "depravity" to be executed.
In contrast, Mohammed al-Issa, the Justice Minister, and Abdulatif Al al-Sheikh, head of the religious police, are cited by liberals as the sort of more moderate Wahhabi cleric that reformers in the royal family want to promote.
Both have fallen foul of conservatives for trying to modernise religious institutions.
Another younger and comparatively liberal cleric, former Mecca religious police chief Ahmed al-Ghamdi, was denounced by older conservative Wahhabis this week for appearing on television with his wife, whose face was uncovered.
Meanwhile the government has promoted an alternative narrative of Saudi identity that keeps Wahhabism as a central focus, but still allows secular themes such as nationalism and cultural heritage that predates Islam to shine.
It has increased national day celebrations that were previously attacked by clerics as undermining religious feeling, and is promoting heritage sites, like the Nabatean rock temples, once seen as embarrassing in the land of Islam.
But it is not clear the whole ruling family supports efforts to reduce the influence of Wahhabism, which gives legitimacy to the Al Saud, said Lacroix.
"A lot of people in the royal family may see it as suicidal," he said.For all the latest business news from the UAE and Gulf countries, follow us on Twitter and Linkedin, like us on Facebook and subscribe to our YouTube page, which is updated daily.
Subscribe to Arabian Business' newsletter to receive the latest breaking news and business stories in Dubai,the UAE and the GCC straight to your inbox.