Saudi Arabia's deputy foreign minister, Prince Abdulaziz bin Abdullah, last year hailed an agreement to establish a centre for inter-religious dialogue in Vienna, stating it would "work for establishing peace and justice and prevent misuse of religion for oppression and violence". King Abdullah himself sponsored a conference for religious dialogue in Madrid attended by representatives of seven major world religions. Quoting a Qur'anic verse, the king told the delegates: "God's will, praise be to Him, was that people should differ in their faiths. If the Almighty had so desired, all mankind would have shared the same religion."

These are noble ideas, but judging from the treatment of the Saudi activist and blogger Raif Badawi, the king's stated goal of religious tolerance applies only to those outside the kingdom's borders. On July 29, a Saudi court convicted Badawi of insulting Islam, saying he had founded a "liberal" website and had insulted religion and religious authorities in television interviews. He was sentenced to 600 lashes and seven years in prison. Though Badawi has the opportunity to appeal, there is little hope that authorities will drop the verdict.

Saudi Arabia, whose legal system is based on uncodified principles of Islamic law, leaves judges largely free to decide what actions, in their view, constitute certain crimes, including serious offenses, such as insulting religion, as well as the appropriate punishments. The results of such a system are unsurprisingly arbitrary and unfair. In fact, local activists say that Badawi's sentence – for establishing a website and peacefully expressing his opinions – is harsher than some sentences for Saudis convicted of terrorism-related offenses.

Shortly after the announcement of the verdict, I asked Badawi's lawyer, Waleed Abu al-Khair, how the judge determined that Badawi's activities constituted an insult to religion. He told me that criminal court judge Faris al-Harbi noted simply that Badawi had created a "liberal" website, and said that "liberalism is akin to unbelief". Expressing sympathy with liberal ideas in Saudi Arabia is apparently all it takes to be jailed and flogged for a religious offense.

Badawi has also faced societal censure for his views. In 2012, the well-known religious cleric Abdulrahman al-Barrak denounced Badawi as an apostate, effectively sanctioning his murder. And Badawi's own father has vigorously condemned him on television shows and in media interviews, saying that his son should be punished. Badawi says he has never attacked Islam, any other religion, or people of religious faith. He has repeatedly said that he merely sought to encourage honest and open debate on religious and political matters in Saudi Arabia, such as the blatant abuses of the Saudi religious police and the use of religion to silence peaceful dissidents and those whose religious opinions differ from those sanctioned by government.

He also campaigned to rescue his sister, Samar Badawi, from domestic abuse. She fled to a Jeddah women's shelter to escape the abuse. Badawi fought to get her out of prison after their father used the criminal justice system to jail her for seven months on the charge of "parental disobedience" – yet another 'crime' whose determination is left wholly to the discretion of individual judges.

Saudi authorities use religion as a tool of oppression in all too many instances. One is the case of Hamza Kashgari, who has sat in a jail cell without charge or trial since February 2012 for three tweets that authorities alleged were insulting to the Prophet Mohammed. Authorities also jailed the well-regarded Saudi novelist Turki al-Hamad in December 2012 after he tweeted a series of comments on religion, finally releasing him in June without charge. These cases demonstrate why the United States Commission on International Religious Freedom has recommended Saudi Arabia as a Tier One Country of Particular Concern, stating that "the government privileges its own interpretation of Sunni Islam over all other interpretations…and continues to imprison individuals for apostasy, blasphemy, and sorcery."

It is hard to imagine how such a horrendous record on religious freedom squares with the kingdom's stated policy of promoting interfaith dialogue and religious tolerance around the world. If the Saudi government intends to have any credibility in fostering religious dialogue and harmony, it must first put an immediate end to invoking religion to punish those who peacefully advocate principles and ideas that the government does not share. The Saudi deputy foreign minister is right – religion should never be used to justify violence and oppression. But to seriously tackle this issue, he needs to look closer to home.

Adam Coogle is a Middle East researcher at Human Rights Watch, who also monitors Saudi Arabia