Treason and Apostasy
In sum, there is no question that the Islamic law of apostasy is a stringent one. Its most probable contemporary analogous case is that of treason. The penalty for treason ranges anywhere from life imprisonment (in many European states that have abolished the death penalty) to the death penalty (such as currently in the United States). The two cases are analogous because the type of apostasy for which a person may face the death penalty is akin to openly revolting against the Islamic state and all that the state stands for.

This point is explained by Sheha as follows,
Sheha, pp. 153-154:
The killing of an apostate from the Islamic faith implies that such a person has violated the basis of Islam and attacked Islam openly and publicly with treachery and blasphemy. As such, he threatens the very basis of the moral and social order. This treachery may precipitate the beginning of internal revolution and dangerous rebellion within the Islamic society. This kind of crime is the most serious in any society, and therefore is called ’High Treason’… Execution of such an apostate is, in reality, a salvation for the rest of the society members from the maliciousness and violence he would spread if left to propagate his disbelief and blasphemy among the other members of the society. If such a person confines his disbelief and apostasy to himself, and does not proclaim and propagate it, he is left to Allah and the punishments of the hereafter. Allah knows best who believes and who rejects faith, who is sincere and who is a hypocrite. Muslim authorities only base their judgments and sentences upon open external matters and leave the internal realties to Allah.

Additionally, Bilal Philips notes the following about the laws of apostasy in Islam,
One who personally abandons the faith and leaves the country would not be hunted down and assassinated. Now would one who apostates privately and remains in the Muslim state conforming to the outward rules of the state be tracked down and executed. The practice of setting up inquisition courts to examine people’s faith is not a part of Islamic legal tradition.

Historically speaking, the “traditional Sunnite” scholars were very reluctant to ever declare an individual a disbeliever or apostate. Naasir al-Aql noted that many famous scholars were known never to utter such a conclusion, although actions which comprise “apostasy” were present around them.  In fact, historically speaking, it was the, as Mayer calls them, “pro-human rights” schisms of the Kharijites and Mutazilah who were known for declaring Muslims outside of their sects as non-Muslims. In fact, those heretical groups were distinguished by two beliefs: al-takfeer (declaring those outside of their fold as non-Muslims) and al-saif (the sword, referring to their belief in the legitimacy of revolting against the rulers). Of course, the one belief leads to the other. The easier it is for people to be considered apostates, such as rulers, the easier it is to accept the concept that they must be revolted against.

It is beyond the scope of this work to touch upon all of the relevant points related to the question of the law of apostasy in Islam  in the light of contemporary thought and attitudes. It is sufficient to note here in the end that if the currently existing laws of treason and laws of war do not constitute violations of human rights, then the Islamic law of apostasy also cannot be considered a violation. Just because one punishment is on behalf of a “state” or “national interest” while the other is on behalf of God or a “religion,” there can be no substantial logical (or possibly legal) difference between the two cases.

Finally, regardless of how many times Mayer may wish to claim tha freedom of religion is “absolute,” as was described earlier, it must be admitted that virtually all societies have to deal internally with its own question of religious freedom. True, the resulting penalty for certain religious practices may not be death but they certainly can be imprisonment, which is still a restriction of freedom.

Donnelly openly discusses this element of “freedom of religion” when he states,
Given the continuing repression of Iranian Bahais—although, for the moment at least, the apparent end to executions—this was quite a sensitive issue. Even here, though, the challenge was not to the principle, or even the right, of freedom of religion (which almost all Muslims support) but to competing “Western” and “Muslim” conceptions of its limits. And we must remember that every society places some limits on religious liberty. In the United States, for example, recent court cases have dealt with forced medical treatment for the children of Christian Scientists, live animal sacrifice by practitioners of santaria, and the rights of Jehovah’s Witnesses to evangelize at private residences.