The gunmen lined them up—men, women, and children—in the village of Ras al-Maa west of Baghdad and unceremoniously slaughtered them all. That was the first in a wave of mass executions last week of tribal figures in Anbar province who dared to defy the militants of the so-called Islamic State. Spectators were then invited to observe the dead while their killers filmed the bloodied, bullet-riddled corpses with their cellphones for social-media sharing.

Those gunned down weren’t Christians or Yazidis or Shia Muslims, the usual victims of the self-proclaimed caliphate’s cruelty. They were Sunni Arabs, and the killings underlined the fact that the violence of the militant insurgency is not reserved for those deemed infidels, but is unleashed against any who oppose it, or who might, including co-religionists.

Across eastern Syria and western Iraq the militants of the Islamic State, widely known as ISIS or ISIL, govern with an iron fist and a sharp eye, purging opponents, brooking no opposition, intolerant of any expressions of dissent or behavior diverging from their diktats no matter how minor or innocuous.

For the militants, religious purity allows no compromises. Even trivial dissent could lead to deviation from the true path and these revolutionary men have, in the words of Arthur Koestler, stripped themselves “of every scruple in the name of a higher scrupulousness.”

Much of the militants’ policing focuses on enforcing their strict interpretation of Sharia law requiring women to cover up and prohibiting them from leaving their homes except when accompanied by male relatives. There are edicts against smoking and drinking alcohol and the school curriculum has been reshaped, eliminating Western subjects such as philosophy, art, sports, or music. All is aimed at inculcating young minds with the ISIS ideology.

Relying on an extensive network of spies and informers to ferret out dissent or any behavior that falls afoul of Sharia, they are alert above all for any signs of a tribal insurrection shaping up against them, since they are determined to avoid the fate of the ISIS forerunner al Qaeda in Iraq.

The killings serve as a warning to others whether they are carried out on the western edge of the so-called caliphate in the town of al-Bab, northeast of the Syrian city of Aleppo, or on the outskirts of the Iraqi capital. They are the equivalent of the Moscow show trials mounted in Stalinist Russia or the mass killings ordered by the Khmer Rouge’s Pol Pot.

As with Stalin’s brutality, so with the Islamic State: “caliphate justice” must be showcased. And so the beheadings and shootings, and in Idlib province the stoning of a woman accused of adultery, are filmed and shared on the Web.

But brutality may also betray a certain vulnerability. According to Richard Barrett, a former head of counterterrorism at Britain’s MI6, the greatest risk for ISIS isn’t from U.S. airstrikes or stubborn Kurdish resistance along the Turkish border, but from dissent and revolt among the Sunni Arab tribes in the vast territory the militants now control.

In a report for the Soufan Group, a security consultancy, Barrett argues the seeds for the caliphate’s demise already have been sown—that the totalitarianism of the Islamic State will provoke a tribe-based uprising.

“In today’s world,” he writes, “no state, however remote, can hope to control its population by limiting its access to information or suppressing its ability to think.”

The militants appear determined to defy that prediction. While they project themselves on the world stage as if they would lead the whole Muslim world, the secret to their success so far is that their politics, while very brutal, also are very local.

The first thing they do on seizing new territory is to drive out Christians and Shia Muslims and wipe out any suspected opponents based on past history, which the ISIS leadership knows in intimate detail.

Hence the mass executions in Ras al-Maa of members of the al-Bu Nimr tribe, which had figured in the 2007 Sunni Awakening by Iraqi tribesmen who had formerly fought against U.S. troops but who realigned themselves to combat al Qaeda in Iraq. Older sheikhs and emirs from suspect tribes are removed by ISIS and replaced by younger ones who are then expected to owe it allegiance.

Once the obvious sources of opposition have been eliminated, the militants watch for little signs of disapproval—grumbling, graffiti, infractions of the dress codes, and many other tiny offenses. And some locals are only too willing to help with enforcement. The Islamic militants have established multiple layers of repression, from Sharia judges to a police force and an intelligence apparatus that relies on an army of informers. That this is hardly unique to ISIS is, precisely, the point. It has learned all the lessons of totalitarianism.

“Wherever you go there are eyes watching you,” says Ziad, a 19-year-old from al-Bab. “Whenever I walk down the street, someone pulls me over asking who I am and why I have not joined Da’esh,” he says, using the Arab acronym for the militant group. “They ask for papers and throw questions at you trying to catch you in lie. People try to stay off the streets.”

Wounded severely in his right leg in an airstrike two years ago, Ziad has an excuse for not enlisting. Other young men in the town are given a harder time, suspected of disloyalty by the very fact of not having joined or standing aside when ISIS holds an event. “About half of the enforcers are locals—they are ones who wear face masks most of the time.”

According to the Washington-based monitoring group the Middle East Media Research Institute, ISIS indoctrination includes “religious jurisprudence” and Quran lessons, quizzes, contests, and “courses with mandatory testing and grading, held in the various provinces.”

There is considerable pressure to attend public events. The militants happily claim that one held in Iraq’s Al-Kheir province, offering instruction in Sharia, attracted butchers, doctors, pharmacists, businessmen, and café and Internet café owners as well as children.

The most feared of the enforcers are the hisbah religious police who patrol the streets of ISIS-controlled towns and villages to ensure compliance with the group’s teachings. But behind them are ISIS fighters and sympathizers and locals eager to curry favor by selling out their neighbors.

“There is no humanity left,” says Mohammad, a student from the Syrian city of Raqqah, the capital of the Islamic State. “I am even wary of my younger brothers, who are all attending Sharia classes and rushing off to Da’esh events.”

“Many people welcome the Islamic State,” he says. “They have brought order—they provide charity, are repairing roads and have cracked down on thieves. But if you aren’t with them, you had better watch out.”

Since the U.S.-led coalition started launching airstrikes against the militants in both Iraq and Syria, security has been even further tightened, say locals who have recently left the “caliphate” or travel back and forth. Civil activists and citizen journalists are high on the target list.

Information received from the different branches of the ISIS network is channeled up through a strict hierarchy. The senior intelligence officers are experienced, having served in similar functions for al Qaeda before or in the intelligence organizations of the late Iraqi President Saddam Hussein or Syrian President Bashar Assad.

Former intelligence officer Barrett may be right that eventually the barbarity of the Islamic militants will prove to be their downfall, but in the meantime the killings and beheadings will continue.