Shaykh Muḥammad ibn Ṣāliḥ al-ʿUthaymīn [d. 1421] said:
[Q]: Is it better for a traveller or a sick person to fast or not?
[A]: We say: It is best for them both to do what is easiest for them. For if there is some harm that comes to either of these categories of people due to fasting, fasting then becomes impermissible, for the saying of the Most High:
وَلَا تَقْتُلُوا أَنفُسَكُمْ ۚ إِنَّ اللَّهَ كَانَ بِكُمْ رَحِيمًا ﴿٢٩﴾
‘And do not kill yourselves [or one another]. Indeed, Allah is to you ever Merciful.’
This āyah proves that whatever causes harm to a person is forbidden with respect to him. If someone was to say: this [āyah] only concerns killing [oneself], not harm in a general sense. [We] would answer: Yes, this is the apparent meaning of the āyah. However, ʿAmr ibn al-ʿĀṣ (may Allāh be pleased with him) used this āyah as an evidence to support the rule of no harm and the Prophet [ﷺ] conceded this interpretation to him. This occurred when he [ʿAmr] was sent as a part of a military detachment and had entered a state of major impurity [janābah] for which he performed tayammum instead of ghusl. So the Prophet [ﷺ] said to him: ‘Did you lead your companions in prayer while you were in a state of major impurity [janābah]?’ He replied: ‘O Messenger of Allāh, you had mentioned the saying of Allāh the Most High: ‘And do not kill yourselves [or one another]. Indeed, Allah is to you ever Merciful.’ The night was cold and thus I opted to perform tayammum. So the Prophet [ﷺ] laughed in approval of his act. This [ḥadīth] is a proof that the āyah encompasses the impermissibility of suicide, just as it comprises refraining from that which causes harm.
Source: Al-Sharḥ al-Mumtiʿ 6:328
Translated by: Riyāḍ al-Kanadī