Islam forbids targeting non-combatants by killing them, kidnapping them, taking them as hostages, or inflicting any kind of harm on them. Taking hostages from combatants is only allowed in wartime, as there are other rules on how to deal with combatants.
Sheikh Faysal Mawlawi, Deputy Chairman of the European Council for Fatwa and Research, states: In general, taking hostages is not lawful in Islam. But it may be practiced against the enemy in a state of war. This is supported by the fact that all the cases in which the Prophet (peace and blessing be upon him) allowed holding hostages took place in war time. Moreover, he (peace and blessings be upon him) did not approve of such cases in which the Muslims took hostages at times when there were no wars going on between the Muslims and the polytheists; on the contrary he (peace and blessing be upon him) ordered that those hostages be set free [unconditionally].
however, bear in mind that even during a state of war, it is not lawful to take as hostages ambassadors, messengers, delegates, those given pledges of security, or the residents who belong to foreign countries.
the Prophet (peace and blessings be upon him) said, “I do not imprison messengers” (Reported by Abu Dawud). Ibn Mas`ud (may Allah be pleased with him) also said, “It is an act of Sunnah that messengers are not to be killed” (Reported by Al-Bayhaqi).
as to those given pledges of security and the residents who belong to foreign countries, it is not lawful to hold them as hostages or kill them. Doing such a thing is a kind of breach [of trust] and Almighty Allah does not like those who breach their trusts. Besides, the Prophet (peace and blessings be upon him) forbade breaching trusts.
So long as taking hostages is an act that may be regarded as lawful only in a state of war, it is not to be directed at those against whom war is not to be launched principally. That is to say, it is not to be directed at the non-combatants—women, children, the elderly, monks [and nuns, priests, etc.]—since those people do not participate in war. Should a non-combatant be held as a hostage [by a Muslim person or group], he or she is to be set free immediately.
hence, it is lawful to take as hostages the enemy warriors, if the Muslim leader has so ordered during war as it was the case when the Prophet (peace and blessings be upon him) asked the Muslims to hold Thumamah ibn Uthal in captivity when they found him. [Keep in mind that Thumamah tried to kill the messenger that the Prophet (peace and blessings be upon him) sent to the king of Bahrain.]
But if the Muslim soldiers hold in captivity an enemy warrior without having been given an order previously from their leader to that effect, they are to hand over this warrior to the leader so that he decides what to do with him.