All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah and that Muhammad, sallallaahu ʻalayhi wa sallam, is His slave and Messenger.
It is known that evils are not of the same degree of gravity; rather, some evils are graver. Evils and harms must be eliminated or avoided as long as this is possible, based on the well-known Fiqh principles: "Harm must be eliminated," and, "There should be neither harm nor reciprocal harm." However, if both evils cannot be eliminated or avoided and there is no other way but to choose one of two evils, then one should opt for the lesser of the two. The graver evil must be eliminated or avoided while enduring the lesser in such a case. There is abundant evidence in the Islamic sharee'ah to this effect. For instance, the sharee'ah allows the Muslim to eat the flesh of a dead animal in case of necessity although the consumption of the meat of dead animals is prohibited in principle and declared an evil; however, the evil incurred by not eating such meat, namely starving to death, is graver.
Another key incident that is used as a basis for this maxim is the hadeeth of the Bedouin who urinated in Al-Masjid An-Nabawi. It has been narrated that a Bedouin once came in and urinated in a corner of the mosque; people begun to reproach him but the Prophet, sallallaahu ʻalayhi wa sallam, stopped them, allowing the Bedouin to finish urinating and remarked, “Do not interrupt him; just bring a bucket of water and throw it over the urine after he is finished...”
An-Nawawi commented on this hadeeth, saying:
“One of the benefits learned from this narration is to repel the graver of two harms by bearing the lesser of the two; the Prophet, sallallaahu ʻalayhi wa sallam, commanded the Companions not to interrupt him. Scholars underlined that by preventing the Companions from forbidding this action two greater harms were avoided. Firstly, the sudden interruption of one urinating could physically harm the individual, and the area had been contaminated with urine already. Thus, enduring the harm incurred by allowing him to finish relieving himself should be given propriety over stopping him at that point (that would have led to a graver harm). Secondly, a small area of the mosque had already been contaminated and moving him at that point would have most likely led to the Bedouin soiling his clothes and body and contaminating other areas of the mosque as well.”
There are many other examples in this regard. Please refer to fataawa ">137489, 87952 and 88254 for examples of the principle of choosing the lesser of two evils (in such situations when both cannot be eliminated or avoided).
Allaah knows best.