If you were a Muslim man who works in the fire and rescue department and there is a burning building with a non-mahram woman trapped in it, can you go and enter it to rescue them but you would probably have to hold them and carry them out?
Basically, even the people holding the opinion that it isn't allowed to touch a non-mahram woman, would allow you to do so in situations where a life is on the stake.
According to this answer:
Also, Islam is a practical religion; it recognizes daroorah, or dire necessity caused by situations that may lead to death. In this case, the ruling is lightened (as are so many rulings) for that situation. For example, if you must touch a woman's hand to save her life (if she's drowning, perhaps) you can do so until she is safe.
For instance, islamQA says the following:
Ibn ‘Aabideen said: “He said in al-Jawharah: if the illness is in any part of her body apart from her private part, it is permitted (for the doctor) to look at it in order to treat it, because it is the matter of necessity. If the sickness is in her private part, he (the doctor) should teach a woman how to treat it. If there is nobody who can do that, and they fear that she may die or suffer unbearably, then they should cover all of her body except the site of the sickness, then a man may treat her, but he should avoid looking at her as much as he can, and look only at the site of the sickness that he is treating.” (Radd al-Muhtaar, 5/237. See also, al-Hidaayah al-‘Alaa’iyah, p. 245).
The key here is the phrase:
it is permitted (for the doctor) to look at it in order to treat it
So according to this article, a doctor is permitted to treat illness in any part of the womens body. The reason it is permitted is because of the situation forces you to do so. This is not restricted to a doctor, it is allowed in any situation where the harm the non-mahram would get is bigger than the "sin" of touching.
We used to take part in holy battles with the Prophet (ﷺ) by providing the people with water and serving them and bringing the killed and the wounded back to Medina. (sunnah.com - Sahih Bukhari)
So it is clear that the women helped the wounded men back to Medina. By helping them, they had to carry them somehow, which means that they somehow "touched" the men.
As stated in the answer to this question: "Is everything that is harmful haram?"
the basic Islamic principle is that everything that is proven to be harmful is haram.
To not rescue someone, is more than harmful because it might lead to direct death. If a woman is in need of CPR to survive, and you as a man know how to do CPR, you should do it in order to save her. You can't let her die.
We should save souls, according to the Quran, 5:32:
And whoever saves one (soul) - it is as if he had saved mankind entirely.
Just because a person might die in a situation and become a martyr, doesn't mean one should strive to die. What if the person, is the only parent of x children? What about them? Their lives might be destroyed because of this.
It is clear that in situations of necessity, you are allowed to touch a non-mahram. It cannot be a sin in these cases, rather you would get hasanat for doing such things due to the verse: "And whoever saves one (soul) - it is as if he had saved mankind entirely."
I would argue that due to the hadith "There should be neither harming nor reciprocating harm." and other variables given, that the one who is able to rescue somebody without putting his own life in danger, would have to try to do so, even though it means touching a non-mahram. Not trying would instead be a sin.
Yes it is allowed to touch a non-mahram in order to rescue them
Emergencies result in relaxation or altogether abandonments of normal circumstance applications. A drowning person can not be let drowned for the reason of avoiding touching a Na-Mehram. It would simply be insane to observe such things in an emergency. Islam, As per Qura'an and several Ahadith--is a logical, rational and easy to practice religion: attending to all possible situations a human being might be facing. Allah likes those who use His conveniences allowed.(Q) Also in(Q-7:199) Prophet (PBUH) was specifically asked to be soft and don't expect too strict a compliance from the followers.
You can eat pork and drink alcohol if you were forced to (death or life matter).
You can say "I don't believe in God" if someone was about to kill you if they know you do.
it is all fine in death or life matters.