The country was founded on an alliance between the Saud family, whose members became the monarchs, and a cleric named Sheikh Muhammad ibn Abdul-Wahhab, whose teachings were used to justify military conquest by labeling it jihad against those deemed to be infidels, most of whom were other Muslims.

Sheikh Abdul-Wahhab’s descendants still dominate the religious institutions of the Saudi state, which now play down the violence in the country’s history and emphasize aspects convenient to an all-powerful royal family, like the importance of obeying the leadership.

Saudi officials reject comparisons between their ideology and that of the Islamic State, noting that millions of non-Muslims live in the kingdom and that the government is closely allied with the United States and participates in the American campaign against the militant group.

They also say that Saudi Islam does not promote the caliphate, as does the Islamic State, and that senior clerics condemn the terrorist attacks and have branded the group “deviant.”

But critics argue that many Saudi clerics have never renounced the aspects of the Wahhabi tradition that the Islamic State has adopted, especially with regard to Shiites, who make up an estimated 10 percent of the kingdom’s 20 million citizens. Many Saudi clerics consider Shiites heretics and accuse them of loyalty to Saudi Arabia’s regional rival, Iran.

The jihadists have exploited this by repeatedly launching suicide attacks on Shiite mosques and then accusing Saudi clerics of hypocrisy for condemning the violence.

“It is clearly hard for Saudi clerics to condemn outright attacks on Shiites,” said Mr. Bunzel, the Princeton scholar. “And you get the feeling that they don’t care as much if the Shiites get attacked, since they’re not really Muslims in their view.”