Capital punishment for offenses is allowed by law in some countries. Such offenses include adultery, apostasy, blasphemy, corruption, drug trafficking, espionage, fraud, homosexuality, treason, and sodomy not involving force, perjury causing execution of an innocent person (which, however, may well be considered and even prosecutable as murder), prostitution, sorcery, witchcraft, and theft. In addition to civilian treason and espionage, often considered capital crimes against the state where the death penalty is retained, military laws frequently ordain execution for serious offences, including in jurisdictions where capital punishment is illegal or obsolete under civilian law.

Adultery

The following countries impose the death penalty for adultery: Afghanistan, Brunei, Iran, Maldives, Mauritania, Nigeria, Saudi Arabia, Yemen, Sudan, Qatar.

Apostasy and blasphemy

Apostasy means renouncing/abandoning/leaving one's religion for another religion (known as conversion) or irreligion (known as deconversion or disaffiliation, including to stances such as atheism, agnosticism and freethought). In the 21st century, this is considered a crime only for Muslims, in a limited number of countries and territories (twenty-five according to Pew Research Center, all of which were located in Africa or Asia), about ten of which include capital punishment as a penalty for it; other jurisdictions may inflict less severe punishments such as imprisonment, a fine or loss of some civil rights, notably one's marriage and child custody. Converting a Muslim to another religion or irreligion is sometimes also criminalised as being an 'accomplice to apostasy'. Apostasy is not known to be a crime liable to any type of penalty for adherents of any other religion in any country in the 21st century. Article 18 of the Universal Declaration of Human Rights (1948) includes the 'freedom to change [one's] religion or belief', therefore any obstruction of apostasy is considered a human rights violation in international law.

Blasphemy means insult, defamation or desecration (sacrilege) of something that or someone who is deemed holy in one or more religions. Unlike apostasy, the religious status of the person suspected or accused of blasphemy is generally regarded as irrelevant; for example, a Muslim may be accused of 'blaspheming' a thing or person deemed holy by some Christians (or Christian organisation or authority), and vice versa, even if that thing or person is not 'holy' to the suspect. In the 21st century, blasphemy is much more widely criminalised than apostasy, in jurisdictions around the world, and is influenced by several religions including Christianity and Islam. , blasphemy could be punished by the death penalty in eight countries, all of which were Muslim-majority.

In some jurisdictions influenced by Sharia (Islamic law), apostasy and blasphemy are closely linked offences. 'Apostasy', or 'public expression of apostasy', is sometimes considered a form, or evidence of, blasphemy; it is then prosecuted as such, even though 'apostasy' itself may not be a crime. This has occurred for example in Pakistan. Likewise, blasphemy is sometimes considered a form, or evidence of, apostasy, and is then prosecuted as such, even though 'blasphemy' itself may not be a (capital) crime. An example of where this situation can occur is Qatar.

Apostasy and blasphemy tend to be closely legally linked to atheism. Formally, being an atheist—or otherwise non-religious person—itself is not an offence in any country, but in practice it is difficult to be an atheist without being able to become an atheist (which is legally impossible for Muslims in many countries, some of which impose capital punishment) or while needing to keep it a secret to everyone that one is an atheist. Therefore, although there is a technical difference between becoming an atheist (a form of apostasy), being an atheist (atheism), and expressing that one is an atheist (which is considered a form of 'blasphemy' by some), some commentators frame the legal situation such that 'being an atheist is punishable by death' or that 'atheism is punishable by the death penalty' in some countries.

Apostasy

As of July 2020, apostasy by Muslims () carries the death penalty in the following countries: Afghanistan, Brunei, Iran, the Maldives, Mauritania, Qatar, Saudi Arabia, Somalia (implicitly), the United Arab Emirates, and Yemen. Malaysia's states Kelantan and Terengganu mandate the death penalty for apostasy, but federal law prohibits execution for this purpose; due to this, it is never implemented in practice. Likewise in Nigeria, some northern states have adopted Sharia law, although execution for apostasy would violate the Federal Constitution, and it is therefore uncertain whether death sentences could actually be carried out. Afghanistan: "According to the Article 1 of the Penal Code, crimes of and , including apostasy, have punishments inflicted in accordance with the Hanafi Jurisprudence of Sharia law, which includes death punishment for non-believers and apostates." Brunei: Section 112(1) of the 2013 Syariah (Sharia) Penal Code (fully implemented in 2019) makes a Muslim who declares himself non-Muslim punishable by death, or with imprisonment for a term not exceeding thirty years and corporal punishment, depending on the type of evidence. If a Sharia Court is satisfied that the accused has repented, the Court must order an acquittal. Iran: Apostasy is not explicitly defined in Iran's civil or criminal legislation, but according to Article 167 of the constitution: "The judge is bound to endeavor to judge each case on the basis of the codified law. In case of the absence of any such law, he has to deliver his judgment on the basis of authoritative Islamic sources and authentic fatwa." Sharia law has been used to punish Muslim apostates with the death penalty. In 1989, Hossein Soodmand, who converted from Islam to Christianity and was a pastor of the Assemblies of God, was murdered for apostasy. The last recorded murder for apostasy in Iran was in 1990.

Malaysia: Apostasy is not a federal crime. Islamic apostasy laws differ from state to state. Malaysia's states Kelantan and Terengganu mandate the death penalty for apostasy, but federal law prohibits execution for this purpose, and so, it is never implemented in practice. The maximum punishment any state can currently convict a Muslim apostate to is 3 years imprisonment. Maldives: "While many religious 'crimes' are not individually spelled out under the penal code, wide berth is given for the prosecution of crimes under Sharia law. The penal code grants judges discretion to impose Sharia penalties, including apostasy and blasphemy." In June 2010, Mohammed Nazim who had publicly declared himself a former Muslim, was arrested by police and given religious counselling by the Islamic Ministry in prison to repent or be executed; Nazim repented and was released. Mauritania: "In 2018, Mauritania enacted a law which makes the death sentence for apostasy compulsory." Nigeria: "The Nigerian Constitution protects freedom of religion and allows religious conversion. Section 10 of the constitution states, 'The Government of the Federation of a State shall not adopt any religion as State Religion.' However, sections 275–279 of the Constitution give constituent states the power to establish their own Sharia courts on civil matters. Abiding by Sharia law is required for Muslims in some states but optional in others and enforcement differs by state. Rulings and procedures are sometimes difficult to find." Although the states of Nigeria have a degree of autonomy to adopt their own laws, the first paragraph of the Federal Constitution stipulates that any law inconsistent with the provisions of the constitution shall be void. The Sharia penal code does contradict the Constitution, yet the federal government has not made a move to restore this breach of the constitutional order, letting the northern Muslim-dominated states have their way and not protecting the constitutional rights of citizens violated by Sharia. It is unclear whether any of the 12 northern states that have adopted some Sharia legislation are carrying out the death penalty, which would violate the Federal Constitution. Qatar: "Converting to another religion from Islam is considered apostasy and remains a capital offence in Qatar (Article 1.1 of Law 11 of 2004)." ... "A blasphemy accusation could be taken as evidence of apostasy" (rather than the other way around). "However since 1971 no punishment for apostasy has been recorded." On its own, blasphemy carries the maximum penalty of imprisonment. Saudi Arabia: In Saudi Arabia Sharia functions as the law of the land, but it is uncodified in statute. "Apostasy is criminalized and mandates a death penalty. The criminal accusation of "apostasy" is sometimes deployed against people (including writers, activists, artists, or lawyers) who show any serious sign of pushing at the outer boundaries of freedom of expression, or who are critical of the religious authorities, and whose views (rightly or wrongly) are termed 'atheist' or as 'insulting to religion'. These laws are actively utilized."

Somalia: "The 2012 provisional federal constitution of Somalia does not explicitly prohibit apostasy but does state that Sharia law comes before federal law."2012 Federal constitution of Somalia 'Article 2: State and Religion. (3) No law can be enacted that is not compliant with the general principles and objectives of Shari'ah.' 'Article 33: Freedom of Belief 1. Every person shall have the right to freedom of belief, and shall not be compelled to adopt another belief. Islamic Sharia does not accept that a Muslim person can renounce his beliefs.';Puntland constitution 'Article 24: Freedom of Faith. 1. No one can be forced to a faith; different from his/her believes. 2. The Muslim person does not have the right to convert from the Islamic faith.', United Arab Emirates: "All citizens of the UAE are deemed to be Muslims. Conversion to other religions (and by implication, advocacy of atheism) is forbidden and the legal punishment for conversion from Islam is death (Article 1 and 66 of the Penal Code), although there have been no known prosecutions or legal punishments for apostasy in court." Yemen: "The act of 'apostasy' is punishable by death. Under Yemeni law "denouncing Islam" or any blasphemy conviction may constitute evidence of 'apostasy'. While the rate of capital punishment in Yemen is very high, the government does not enforce the death penalty for apostasy in practice: the law allows those charged with apostasy three opportunities to repent, which absolves them from the death penalty. It is unclear whether a moratorium is in place or whether an 'apostate' who refused to repent would face the death penalty. Family law prohibits marriage between a Muslim and an apostate; by law, apostates have no parental or child-custody rights."

Blasphemy

As of July 2020, blasphemy can be punished by death in Afghanistan, Brunei, Iran, Mauritania, Nigeria (some northern states), Pakistan, Saudi Arabia and Somalia (al-Shabaab-controlled areas).

Afghanistan: Blasphemy law in Afghanistan is defined by the Penal Code of 1976, which addresses "Crimes Against Religions", but leaves the issue of blasphemy to Sharia. Sharia permits the authorities to treat blasphemy as a capital crime. The authorities can punish blasphemy with death if the blasphemy is committed by a male of sound mind over age 18 or by a female of sound mind over age 16. Anyone accused of blasphemy has three days to recant. If an accused does not recant, death by hanging may follow.