قَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم " مَنْ بَدَّلَ دِينَهُ فَاقْتُلُوهُ "
The Prophet said, "Whoever replaces his religion, execute him."
In order to understand this issue, we need to examine the Islamic law on apostasy. Since religion is looked on as a personal affair in western society, the notion of state intervention in one's personal choice would naturally seem excessive. However, from the Islamic perspective, a number of points must be observed with regard to apostasy:
1. Islam has never compelled anyone to accept the religion. Anyone who becomes a Muslim does so purely through objective study of the religion. As Allah has informed us in the Qur'an:
2:256 There is no compulsion in religion.
10:99 So would you (O Muhammad) then compel people to become believers?
Likewise, Islam encourages its followers to reflect and contemplate upon the universe around us and to ponder over the beauty of the Qur'anic message:
47:24 Do they not ponder over the Qur'an or are their hearts locked up?
51:20-21. And on earth are signs for those endowed with inner-certainty; and [likewise there are signs] in yourselves, do you not observe?
29:20 Say: "Travel through the earth and see how Allah did originate creation; so will Allah produce a later creation: for Allah has power over all things.
Thus, Islam requires that one's faith be constructed upon logical investigation and study of the universe in which we live. Through logical contemplation, one realizes the supreme authority of the Creator and the veracity of Muhammad's (saws) claim to prophethood. Thus we find that, in the history of Islam, no knowledgeable Muslim has ever left Islam. The only cases we find of former Muslims are people who were never practicing Muslims in the first place, nor did they ever have a good understanding of Islam. Yet on the other hand, the list of educated converts to Islam is immense, and it includes educated leaders such as priests, rabbis and atheists.
2. Those who have left Islam have historically fallen under three categories: those who left having never properly understood the religion often due to social circumstances, those who faked a conversion into Islam in order to undermine the Islamic community from within, and those who left to support opposing forces in battle against the Muslims. Because of the first category, Islam requires that the person who has chosen to forsake the religion be consulted with in order that his doubts may be clarified to him if there is any specific issue of confusion, or so that he may learn the proper Islamic teachings that he may otherwise have not been exposed to. As for the second and third category, this was the original reason behind the Prophet's statement on apostasy. The Qur'an records (3:72) that the Jews of Madinah decided to initiate the practice of pretending to accept Islam and then publicly declare their rejection of it, so as to destroy the confidence of the newly-converted Muslims. Thus, the Prophet Muhammad pbuh ruled that a punishment should be announced so that those who decide to accept Islam do so because of a firm conviction not in order to harm the Muslim community from within.
3. Coming to the actual law of apostasy, the Prophet Muhammad pbuh did say, in the above historical context, "Whoever replaces his religion, execute him" (Bukhari, Abu Dawud) but how exactly do we understand this statement and does it conflict with the principles of freedom? The Prophet Muhammad pbuh himself clarified this statement in another hadith narrated in Sahih Muslim where he mentioned that the one who was to be fought against was the one who "abandons his religion and the Muslim community". It should be noted that every country has maintained punishments, including execution, for treason and rebellion against the state (See Mozley and Whitley's Law Dictionary, under "Treason and Treason Felony," pp. 368-369). Islam is not just a set of beliefs, it is a complete system of life which includes a Muslim's allegiance to the Islamic state. Thus, a rejection against that would be akin to treason. Rebellion against God is more serious than rebellion against one's country. However, one who personally abandons the faith and leaves the country would not be hunted down and assassinated, nor would one who remains inside the state conforming to outward laws be tracked down and executed. The notion of establishing inquisition courts to determine peoples' faith, as done in the Spanish Inquisition, is something contrary to Islamic law. As illustrated by the historical context in which it was mandated, the death penalty is mainly for those who collaborate with enemy forces in order to aid them in their attacks against the Islamic state or for those who seek to promote civil unrest and rebellion from within the Islamic state. When someone publicly announces their rejection of Islam within an Islamic state it is basically a challenge to the Islamic government, since such an individual can keep it to themselves like the personal affair it is made out to be.
4. From Islamic history, we can gain a better understanding of how this law has been implemented. Although the Prophet Muhammad pbuh threatened the death penalty in response to the attempts against the Muslim community, no such executions took place in his time (Imam Shawkani, Nayl Al-Awtar, vol. 7, p. 192) even though there is a report that a Bedouin renounced Islam and left Madinah unharmed in his time (Fath Al-Bari vol. 4, p.77 and vol. 13 p. 170; Sahih Muslim biSharh An-Nawawi, vol. 9, p. 391). Thus, we find that context plays an important role in determining how to deal with apostates. The case of one who enlists nations to fight against the Islamic state is more serious, for example. That is why the scholars of the Hanafi school of thought felt that the punishment only applies to the male apostate and not the female apostate because the latter is unable to wage war against the Islamic state. If someone simply has some doubts concerning Islam, then those doubts can be clarified.
So an Islamic state is certainly justified in punishing those who betray the state, committing treason and support enemy forces. As for anyone else, if they do not publicly declare their rejection of Islam, the state has no interest in pursuing them; if their case does become public, however, then they should be reasoned with and educated concerning the religion so that they have the opportunity to learn the concepts they may not have understood properly and they can be encouraged to repent.