Reference: Kayfa Nu’aalij Waaqi’unaa al-Aleem – Page 117
Question: There are those who tie a magazine of explosives around their waist, then they enter a government or residential building or a gathering of people either disbelievers or other than them, then they blow themselves up, so what is the ruling regarding this? And is something like this act considered an aspect of jihaad, and is the one doing so considered a martyr or one who has committed suicide?
Response: No doubt on the face of it he is one who has committed suicide, whereby he has made certain he will be killing himself before anyone else. However, this can be permissible if he is in a warring territory of the disbelievers, and knows he will sooner or later be killed at the hands of the enemy, or will face severe torture and has not found any ploy except to blow himself up and kill others from the enemy [who subject the Muslims to torture] along with himself. In doing so, killing a number of them thereby weakening their strength/force and reducing their harm and scaring them. So this can be permissible even if it involves killing the person himself, if he knows he will certainly be killed, or persecuted and wishes to rid himself of their harm and attain ease for himself, and his matter is with Allaah the Almighty.