Praise be to Allah.
What your friend told you about it being permissible to speak words of disbelief in order to protect oneself from harm or persecution that cannot be borne is correct. That is affirmed in the Qur’an, and in the Sunnah there are reports which support it, and the scholars did not differ concerning that.
In the Qur’an:
Allah, may He be exalted, says (interpretation of the meaning):
“Whoever disbelieved in Allah after his belief, except him who is forced thereto and whose heart is at rest with Faith but such as open their breasts to disbelief, on them is wrath from Allah, and theirs will be a great torment”
At-Tabari (may Allah have mercy on him) said:
It was narrated that Ibn ‘Abbaas said: Allah, may He be glorified, states that whoever disbelieves after having believed is subject to the wrath of Allah and will have a severe punishment. However, in the case of one who is forced to speak words (of disbelief) that are contrary to what is in his heart of faith, in order to save himself from his enemy thereby, there is no blame on him, because Allah may He be glorified, will only bring people to account for what they intend in their hearts.
Tafseer at-Tabari (17/305)
In the Sunnah:
The mushrikeen seized ‘Ammaar ibn Yaasir and did not let him go until he reviled the Prophet (blessings and peace of Allah be upon him) and spoke well of their gods, then they let him go. When he came to the Messenger of Allah (blessings and peace of Allah be upon him) he said: “What happened to you?” He said: Something bad, O Messenger of Allah; I was not let go until I reviled you and spoke well of their gods. He said: “How do you find your heart?” He said: It is at rest with faith. He said: “If they do that again, do the same again (as you did).”
Narrated by al-Haakim in al-Mustadrak (2/389); al-Bayhaqi in as-Sunan al-Kubra (8/208). Its isnaad is da‘eef, but it was narrated via many isnaads which indicates that there is a basis for this story.
Al-Haafiz Ibn Hajar (may Allah have mercy on him) said:
These mursal reports strengthen one another.
Fath al-Baari (1`2/312)
With regard to scholarly consensus:
(a)Ibn Hazm (may Allah have mercy on him) said:
The scholars are unanimously agreed that the one who is forced to say words of disbelief when his heart is at rest with faith is not subject to any blame before Allah, may He be exalted. End quote.
Maraatib al-Ijmaa‘ (61). See also: al-Iqnaa‘ fi Masaa’il al-Ijmaa‘ by Ibn Qattaan (2/272)
(b)Shaykh al-Islam Ibn Taymiyah (may Allah have mercy on him) said:
Hence there is no dispute in our view that the ruling on words uttered is not applicable in the case of one who is forced unlawfully. End quote.
(c)In al-Mawsoo‘ah al-Fiqhiyyah (22/182) it says:
The fuqaha’ are unanimously agreed that if a person is forced to disbelieve and utters the word of disbelief, he does not become a disbeliever thereby. End quote.
The compulsion for which a person is excused is compulsion in which a person has no option but to resort to saying such words.
It says in al-Mawsoo‘ah al-Fiqhiyyah (22/182):
Compulsion is of two types: that in which one is compelled to resort to desperate measures, such as threats of killing, cutting off of limbs and beatings in which one fears loss of life or limb, whether the blows are few or many. This type is called “complete force”.
With regard to the other type, one is not compelled to resort to desperate measures. That includes imprisonment, being tied up or being beaten, but not to the degree that one fears loss of life or limb. This type of compulsion is called “lesser force”.
The scholars have listed certain conditions regarding the definition of complete force in which one may resort to speaking words of disbelief; they are as follows:
(a)The threat should be of something that causes destructive harm, such as killing or cutting off limbs, or it should be something that the Muslim cannot bear, such as imprisonment and beatings.
(b)The one who is forcing him should be in a position where he is able to carry out his threats.
(c)The one who is forced should be unable to protect himself, even if that is by running away or seeking the help of others.
(d)The one who is being forced should think it most likely that what the one who is forcing him is threatening him with will indeed happen.
See also the answer to question no. 70558 in which there is an important quotation from Ibn Qudaamah al-Maqdisi concerning this topic.
Is it permissible for the one who is being forced to bear it with patience and put up with the harm and persecution, even if he is killed in the process?
Yes, it is permissible for him to do that. This is what was done by Bilaal ibn Rabaah (may Allah be pleased with him) and others.
Ibn Katheer (may Allah have mercy on him) said:
It is permissible for him to accept being killed, as Bilaal ibn Rabaah (may Allah be pleased with him) referred to comply with their demands that he utter the word of kufr, when they were torturing him in all kinds of ways, to the extent that they put a huge rock on his chest when it was intensely hot, and they ordered him to ascribe partners to Allah, but he refused to do that and kept saying “Ahad, Ahad (One, One).” And he said: By Allah, if I knew a word that would annoy you even more than this, I would say it. May Allah be pleased with him and make him pleased.
Tafseer Ibn Katheer (4/606)
Which is better: to be patient and bear it, even if that leads to death, or to avail oneself of the concession allowed by Islam and pay lip service to disbelief?
The most correct view is that what is best is to be patient and bear it, especially for someone who is one of the people of knowledge and virtue, or is an example for people. This is the view of the majority.
Ibn Katheer (may Allah have mercy on him) said:
What is best and is preferable is for the Muslim to remain steadfast in his faith, even if that leads to him being killed.
Tafseer Ibn Katheer (4/606)
In al-Mawsoo‘ah al-Fiqhiyyah (35/18) it says:
The Hanafis, Maalikis and Hanbalis are agreed, and it is the more correct view according to the Shaafa‘is, that being patient and remaining steadfast in faith when one is being subjected to compulsion, even if that leads to being killed, is preferable to committing acts of disbelief, and if a person is killed he will be rewarded, because of the report according to which the Messenger of Allah (blessings and peace of Allah be upon him) said: “Among the people who came before you, a man would be taken and put into a hole dug for him in the earth, then a saw would be brought and put on his head and he would be cut into two halves, and an iron comb would be used to tear the flesh from his bones, but this still did not turn him away from his religion.” Narrated by al-Bukhaari.
On the other hand, the Shaafa‘is stated the following:
1.It is preferable to utter the word of disbelief in order to protect oneself
2.if he is one of the scholars who are taken as an example, then it is preferable to remain steadfast.
3.If what is expected of him is that he will be able to stand up to the enemy and to support Islam, then it is preferable for him to utter the word of disbelief in order to survive, otherwise it is preferable for him to remain steadfast.
Shaykh al-Islam Ibn Taymiyah often mentioned the hadith quoted above about those among the people who came before us who remained steadfast in the face of such terrible acts of torture and killing, then he said:
It is well-known that the Prophet (blessings and peace of Allah be upon him) only mentioned that in the context of praising those people for their patience and steadfastness, and so that this may be a source of pride for the believers of this ummah.
End quote from al-Istiqaamah (2/332)
The questioner said: “what I know is that it is not permissible for anyone to say that he is not a Muslim, no matter what the reason; rather he must be proud of his Islam under all circumstances.”
One may think that these words are supported by what is narrated in the Sunnah from Abu’d-Darda’ (may Allah be pleased with him), who said: My close friend (blessings and peace of Allah be upon him) advised me: “Do not associate anything with Allah, even if you are cut and burned. Do not neglect any prescribed prayer deliberately, for whoever neglects it deliberately no longer has the protection of Allah. And do not drink wine, for it is the key to all evil.”
Narrated by Ibn Maajah (4034); classed as hasan by al-Albaani in Saheeh Ibn Maajah.
But in fact this hadith does not mean that it is not allowed to avail oneself of the concession; rather it clearly highlights what is best in the case of compulsion. We have stated above that the view of the majority is that what is best is to be patient and remain steadfast. However the concession is proven in the Book of Allah, may He be exalted.
Abu’l-Hasan al-Mubaarakfoori (may Allah have mercy on him) said:
This indicates that one should choose death and being killed without making any outward display of ascribing partners to Allah; this is advising what is best and more virtuous. Otherwise it is permissible to utter words of disbelief and shirk if one is forced to do so, because Allah, may He be exalted, says (interpretation of the meaning): “except him who is forced thereto and whose heart is at rest with Faith” [an-Nahl 16:106].
Mar‘aat al-Mafaateeh Sharh Mishkaat al-Masaabeeh (2/283)
In fact what the one who is forced says, even if it is in and of itself shirk, it is not really shirk in his case and he cannot be called a mushrik because of it. Rather he is still a believer; his faith is not affected at all and he has not fallen into shirk. The words that he was forced to say do not count for anything, so long as his heart was still at rest with faith. In that case he has not gone against this hadith and he has not ascribed any partner to Allah.
However the real problem is that some of them may be afraid of being killed or persecuted or other kinds of harm, or they may fear losing some benefit, so they fall into shirk, accept it and become at ease with it. In that case a person does become a mushrik and apostate.
And Allah knows best.