Last week, a Burmese woman in Saudi Arabia who'd been convicted of abusing and murdering her step-daughter met Saudi justice: police dragged her through a street in Mecca and held her down as, in full public view, she was gruesomely beheaded. When a clandestine recording leaked to YouTube (it has since been pulled), the Saudi government defended its latest public beheading as necessary to "implement the rulings of God," warning any who might commit a similar crime that "the rightful punishment is their fate."

This execution, Saudi Arabia's 10th in January alone, is representative of the country's extreme and often horrifying justice system. Those practices have come under renewed international attention over Saudi blogger Raef Badawi, who was sentenced to 1,000 lashes, carried out over 20 weeks, for speaking up in defense of atheists and ridiculing religious figures. His most recent round of 50 lashes has been postponed — according to Saudi authorities, because the last 50 were so painful that he might not survive another round in his current state.

The story of why and how Saudi Arabia's justice system became so notoriously barbaric is more complicated than you might think. It's in many ways 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.

This is all built on a 270-year-old Faustian bargain between the Saudi clan and a fundamentalist leader

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 Muhammed 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."

With the support of Wahhab and his followers, by the early 1800s the Saudi family had expanded their control from a small holding in the center of the Arabian peninsula to essentially all of what we now call Saudi Arabia, an area larger than present-day Mexico. As Saudi political control spread, so did the power of the Wahhabi clerical establishment. And as the empire grew, so did Saudi reliance on Wahhabi doctrine to unify and rule.

Why the Wahhabists wanted to bring back ancient practices

The Ottoman Empire destroyed the Saudi state in 1818, but Saudi rule returned a century later, reestablishing Saudi Arabia as we now know it 1932. The Saudi-Wahhabi alliance remained the core of the national ideology, and remains so to this day.

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.

In the Wahhabi view, punishments such as public beheadings, though seen as barbaric by virtually the rest of the world — including the Muslim world — 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.

The Saudis keep these practices not out of religious devotion, but because of politics

Over the past several decades, as individual members of the Saudi royal family have grown up far more exposed to outside ideas and formal education, they have drifted away from the country's Wahhabi roots. That has included some modest reforms to the justice 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 medieval punishments 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 these punishments are a way of appeasing those clerics. Second, the Saudi royal family is a dictatorship that earnestly fears unrest, and uses severe punishments 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 one way that the Saudis continue to allow 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 over 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.

Brutal punishments such as public beheadings are one way that the Saudis do this. The monarchy has given little indication 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 historically 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."

Saudi Arabia is unique

It's tempting to use Saudi Arabia, one of the largest and most powerful Arab states, as a proxy for the legal systems in Arab states as a whole. But that's not fair. Saudi law takes a much stricter interpretation of Islamic law than almost all of its neighbors, and Saudi practices are viewed with horror in much of the Middle East.

That's because the Faustian pact between Wahhabi clerics and the al-Saud family is unique. Though many nations use sharia as a source of inspiration in their legal codes, no other Arab country is explicitly founded as clerical-Wahhabi states.

Reform is not impossible. Caryle Murphy documented a number of promising signs in an interesting Foreign Policy essay, including growing diversity of religious thought and declining public support for sharia law. Saudi women are challenging some of the particularly absurd gender rules, like the ban on women driving.

But don't expect an end to flogging or beheading anytime 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 themselves in power.