WESTERN leaders have long urged Muslims to do more to counter jihadist ideology. This month Barack Obama said moderate Muslims, including scholars and clerics, had a responsibility to reject “twisted interpretations of Islam” and the lie “that America and the West are somehow at war with Islam”. On February 23rd Tony Abbott, Australia’s prime minister, urged Muslim leaders to say that Islam is a religion of peace—“and mean it”.

Muslims have not taken kindly to such hectoring. Yet they are starting to debate the role that Islamist ideology plays in extremism. On February 22nd Ahmed al-Tayeb, the grand imam of Egypt’s al-Azhar mosque, part of a university that is the Sunni world’s oldest seat of learning, declared that extremism was caused by “bad interpretations of the Koran and the Sunna [the doings of the Prophet Muhammad]”, and that what was taught in Islamic schools and universities needed to change.

The doctrines of jihad and takfir are central to the debate. Extremists interpret jihad as mandating offensive holy war, though they may disagree about when and against whom it should be waged. The evidence from the hadith (the Prophet’s sayings) and renowned scholars that Islam is a religion of the sword is “so profuse that only a heretic would argue otherwise”, claims the most recent issue of Dabiq, the magazine of Islamic State (IS). Extremists differ, too, about takfir, the process whereby Muslims declare other Muslims to be apostates or unbelievers, for which the penalty is death. Al-Qaeda applies the doctrine with some limits to avoid alienating Muslims from its cause; IS invokes takfir wholesale, especially against Shias, perhaps in the belief that cinematic gore is the stronger lure.

Mainstream clerics are trying to rebut such views. “Jihad does not mean holy war but striving to achieve peace and anything good in obedience to Allah,” says Dauda Bello, an imam from Nigeria’s north-eastern region, where Boko Haram, an Islamist insurgent group, rampages. Last year 120 Muslim scholars wrote to Abu Bakr al-Baghdadi, IS’s leader, saying that he had misconstrued Islam by ignoring the context of the Koran, classical teaching and the current era. Takfir, they said, can only be pronounced on those who have openly professed unbelief. It is properly carried out only by ulema (a group of recognised experts in sacred law and theology), which will first offer the opportunity to repent. To prove the point, al-Azhar will not call IS non-Muslims.

The authority of al-Azhar, Tunisia’s Zitouna mosque and Saudi Arabia’s University of Medina rests on their long histories and tradition of scholarship. The approach of al-Azhar, which was founded in 970 and led the integration of Islamic and secular subjects, is “based on teachings which the Muslim umma [community] has approved over thousands of years”, says Muhammad Mehanna, an adviser to Mr Tayeb.

But Sunni Islam, unlike the Shia form, has no pre-eminent doctrinal authority, nor, since Ataturk ended the already weakened caliphate in 1922, anything resembling a single leader. This makes it harder to hold the line against extremists. Four schools of sharia law and thousands of hadith allow much room for interpretation. Both IS and Boko Haram argue from primary sources and ancient scholars. Supporters of IS point out that their leader has a PhD in Islamic studies from Baghdad University and claims to be of noble and learned stock.

Governments in the Middle East are trying to counter such new claims of authority by imposing their own versions of Islam. Last year Egypt sacked 12,000 preachers and replaced them with al-Azhar graduates, who must preach on government-approved themes. Saudi Arabia, which itself espouses a puritanical form of Islam, has long co-opted clerics with cash and is adding CCTV in mosques (ostensibly to prevent theft). Overhauling religious education in schools is being discussed, too. In 2012 the Carnegie Endowment for International Peace, a think-tank in Washington, DC, found that Egyptian textbooks embraced jihad against both infidels and enemy countries. Callers to a recent radio show about radicalisation on FM Masr, an Egyptian station, said such books needed to be rewritten. In Nigeria imams are setting up schools that combine secular and Islamic education, since teachers in traditional religious schools are often low-level imams barely out of their teens.

Complicating attempts to shore up traditional sources of authority is the fact that the establishment is precisely what many extremists reject. Salafists (devout Muslims who seek to emulate the times of the Prophet), both of the quietist and the violently jihadist sort, see much of the centuries-old tradition of Islamic jurisprudence as distorting the true religion. When denounced by the emir of Kano, a former central banker who is now Nigeria’s second-most-important Muslim leader, Boko Haram retorted: “We do not practise the religion of Lamido Sanusi…but the religion of Allah.”

And Muslim-majority populations that have risen up against dictators are less willing to trust religious authorities—especially those they regard as captured by political or government interests. Egypt’s government appoints the head of al-Azhar. Members of Dar al-Ifta, Lebanon’s official body for teachings and fatwas (rulings on Islamic law), come from its two main political groupings. Middle Eastern rulers have a history of alternately backing religious groups and denouncing them as terrorists for short-term political gain.

The internet, social media and improving literacy in the region make other sources easier to find. “I think about religion myself by searching and seeing the different opinions,” says Muhammad Gamal, a chemistry teacher at Cairo University. Alternatives are often better packaged and more appealing to young people, too. A region-wide joke says that Mr Baghdadi, in his 30s, is the youngest person to head an Arab organisation.

“You see ISIS videos, all slick Hollywood style, and what a stark contrast with the turbans and robes of the sheikhs of Al-Azhar,” says Raphaël Lefèvre, a French scholar who studies Lebanon’s Sunnis. “Radical groups seem closer to the people. Institutions are seen as bourgeois, stuffy and speaking a language people don’t understand.” Some Muslim scholars compare the appeal of jihadism to that of fundamentalist Christianity: the message is clear and certain.

Firm government action against those who preach violence is probably worthwhile. And traditional centres of Islamic authority could surely do more to explain their interpretations of Islam, and in more appealing ways. But the result of the debate within Islam about the roots of extremism may not be entirely to the taste of liberal Muslims—or Western politicians.

Imposing state-sanctioned creeds has in the past pushed jihadists underground. And these versions of Islam are by no means sure to be more liberal: the Saudi regime uses harsh sharia punishments such as beheading and last year al-Azhar launched a campaign to rid Egypt of unbelief after a survey claimed the country held precisely 866 atheists. But the alternative, attempting to promote liberal doctrines in a free market of religious ideas, has dangers, too. Georges Fahmi, an Egyptian scholar, detects a conservative mood among Muslims: “What is shocking is how many people support IS’s actions even if they would not do them themselves.”