Saudi Arabia is set to behead a man and publicly display his headless body (a practice called "crucifixion" in Saudi law) — for nothing more than speaking his mind. Sheikh Nimr Baqir al-Nimr, an internationally respected Shia cleric, was sentenced to death for "disobeying the ruler," "inciting sectarian strife," and "encouraging, leading and participating in demonstrations." His actual crime: participating in nonviolent protests and calling for the fall of the house of Saud.

It's not clear when the Saudis plan on executing al-Nimr: the country has a habit of both postponing executions and carrying them out without very much warning. But the case illustrates a basic fact about one of America's closest allies in the Middle East: its system of capital punishment is one of the cruelest on earth.

Why is Saudi capital punishment so barbaric? In many ways, the story is less about religion than it is about Saudi Arabia's unusual politics; yes, Saudi Arabia has politics. At the heart of it is the relationship between the Saudi monarchy and the country's ultra-conservative clerical establishment — an arrangement that dates back to 1744.

Saudi Arabia is a world leader in gruesome executions

According to Amnesty International's latest figures, Saudi Arabia executed at least 90 people in 2014. That is more people than any other country except Iran and almost certainly China (human rights groups estimate China conducts hundreds or even thousands of annual executions).

"Most death sentences in Saudi Arabia are carried out by beheading, often in public," Sevag Kechichian, Amnesty's Saudi Arabia specialist, writes. Sometimes the Saudi government defaces the corpses afterward. The Death Penalty Database found "reports that Saudis have exposed the body (with head sewn back on) of the condemned to public indignity, including crucifixion, after execution."

Many of these people are executed for nonviolent crimes: in 2014, 42 of the 90 people executed were convicted on drug-related charges. Their trials generally didn't even come close to being fair.

"Trials in death penalty cases are often held in secret. Defendants are rarely allowed formal representation by lawyers, and in many cases are not informed of the progress of legal proceedings against them," the Amnesty report found. "They may be convicted solely on the basis of 'confessions' obtained under duress or involving deception."

Saudi Arabia's legal system is deeply theocratic. The interpretation of Sharia law that dominates the Saudi criminal system is extremely harsh, and is viewed with horror in much of the Middle East. Which raises an obvious question: if Saudi Arabia's barbaric system is such an outlier in its region, how exactly did it get so terrible in the first place?

The politics behind Saudi Arabia's fundamentalism

In 1744, when the place we now know as Saudi Arabia was divided among many fractious clans, a minor clan leader named Mohammed ibn al-Saud met Muhammad ibn al-Wahhab, a Sunni religious figure preaching an austere, puritanical interpretation of Islam. They struck an alliance: Wahhab would support the Saudi family as political rulers, and the Saudis would spread Wahhab's ultra-conservative doctrine and let him set religious code within their territory.

Wahhabism, as Wahhab's doctrines came to be known, gave al-Saud a believing tax base and an ideological justification for uniting the peninsula under his rule. "Without Wahhabism," London School of Economics Professor Madawi al-Rasheed writes, "it is highly unlikely that ... [Saudi] leadership would have assumed much political significance."

The Wahhabi movement played an integral role in the Saudi rise to power, and while much happened between then and now (including the al-Sauds' loss of power), the power-sharing Saudi-Wahhabi alliance remains the core of the state ideology to this day.

That the punishments are medieval is the point

Wahhabism is a sort of fundamentalist revivalism, emphasizing a return to what its ultra-conservative proponents see as the core and original Muslim values. As such, it takes a fairly literalist view of Islamic law — and is willing to use the force of the state to back that up.

Punishments such as public beheadings are seen as barbaric by virtually the rest of the world — including the Muslim world. But in the Wahhabist view they are justified and, indeed, important, because they are perceived throwbacks to the Prophet Mohammed's seventh-century rule, and one of many ways in which the Wahhabists sought to turn back to clock to what they saw as a better era. That the punishments are medieval is the point.

In this view, "the death penalty or stoning for adultery and fornication, flogging and amputation for stealing, and punishments of retribution are sanctioned by the Quran and are unchangeable," legal scholar Shahid M. Shahidullah explains. Wahhabist interpretation of "sharia law is the exclusive foundation of criminal justice" in Saudi Arabia.

So the centuries-old political bargain between the Wahhabis and the ruling explains why the Saudi criminal code sanctions such brutal punishments.

Why terrible Wahhabist punishments persist to this day

In more recent generations, members of the Saudi royal family have been more likely to grow up exposed to outside ideas and educations, shaped by Western boarding schools and colleges as well as lots of time abroad. As that's happened, those individuals have drifted away from the country's Wahhabi roots.

That has brought some modest reforms to the justice system. But it has not changed the underlying system.

"Successive monarchs of the kingdom supported selective modernization of the kingdom in many areas, including law and justice," Shahidullah writes. "It is for this relatively liberal perspective of the Saudi ruling monarchy that a number of law and justice institutions have recently grown to establish strict procedural guidelines on the implementation of sharia law."

And yet, the beheadings remain. There are two main reasons for this, both of which have far more to do with politics than religion.

First, the Saudi royal family still believes it needs the support of the ultra-conservative clerical establishment to hold power, just as it did in the 1700s. And brutal punishments are a way of appeasing those clerics. Second, the Saudi royal family is a dictatorship that earnestly fears unrest, and uses executions as one of several tools to stifle dissent or grassroots organizing.

"This situation puts Saudi Arabia at odds with the rest of the Arab world"

That first point, though, may be the most important. The Saudi monarchy sees itself as stuck between a powerful, ultra-conservative clerical establishment on one side and the practical realities of running a modern country on the other. Public beheadings are a means for the Saudi rulers perpetuate Wahhabist control over religious matters, and thus preempt Wahhabist opposition to the monarchy's modest modernizations and pro-Western foreign policy.

This tension has long defined the country: in 1979, religious extremists seized the Grand Mosque in Mecca, demanding the overthrow of the Saudi monarchy for betraying ultra-conservative Islamist ideals. The siege, which killed more than 200 people, led the Saudis to try to prevent future attacks by co-opting radical Islam where it could — to be more extremist than the extremists.

In 1991, when elements of the Saudi clerical establishment practically revolted over the monarchy allowing US troops to temporarily base there, the monarchy again responded by co-opting the extremists, encouraging them to fund jihadists abroad rather than make trouble at home.

Public beheadings are one way the Saudis do this. The monarchy has given little indication that it considers human rights a priority, so it has been seemingly quite willing to trade them away.

In return, the religious establishment has rewarded the monarchy with loyalty that has been crucial to keeping the Saudis in power. "In every crisis the regime has faced since the founding of the modern Saudi state," Texas A&M's F. Gregory Gause writes, "the Wahhabi clerics holding high positions in the state religious hierarchy have rallied to the colors."

Even when it comes to something like commercial law, where the haphazard nature of Sharia law does actual harm to the Saudi economy and thus the regime's coffers, the monarchy has been hesitant to try to reform the religious courts.

"This situation puts Saudi Arabia at odds with the rest of the Arab world, where modernizing governments have steadily hemmed in religious courts," Dickinson College historian David Commins writes. "It appears as though the Saudi rulers lack the confidence to challenge directly the Wahhabi ulama, perhaps from a sense that the dynasty's claim to legitimacy is questionable."

And don't expect an end to beheadings soon. The Wahhabi establishment, and its harsh vision of criminal law, are deeply embedded in the Saudi state, and seen by the monarchy as essential for keeping itself in power. The numbers bear that out: according to Amnesty, Saudi Arabia executed more people in 2014 than it had in any of the past three years.