The Messenger of Allaah, sallallaahu ‘alayhi wa sallam, said,
“If you hear of a plague in a land, do not enter therein. If it befalls a land and you are in it, then do not go out of it.”
(Al-Bukhaari: 5728, Muslim: 2218)
He ﷺ also said,
“The one who flees from the plague is like one who flees from battle, so whoever endures patiently will have the reward of a martyr.”
(Ahmad: 14793, 24527)
As science advanced, hidden worlds of tiny creatures were revealed, as were the means of their reproduction, spread and their causing of illnesses and epidemics.
It became clear that those who appeared healthy could be carrying microbes of disease and that they were a real source of risk in transmitting the epidemic to other places through travel.
Due to this revelation, a globally recognized and current system of quarantine was developed. It restricts all residents of an afflicted city from leaving, just as it restricts others from entering.
Waves of plague struck Europe in the 15th century until one-fourth of the population was wiped out. Its fury broke off at the borders of the Islamic world. During that period, deadly epidemics and contagious diseases were much fewer in the lands of Islam compared to Europe.
Allaah's Messenger, sallallaahu ‘alayhi wa sallam, founded a basic principle that only became an essential part of modern preventive medicine after the discovery of germ-causing illnesses and epidemics. This is the principle of quarantine, which prevents the spread of diseases that threaten whole cities and societies.
He, sallallaahu ‘alayhi wa sallam, regulated this scientific fact by saying, “If you hear of a plague in a land, do not enter therein. If it befalls a land and you are in it, then do not go out of it.”
To guarantee the implementation of this great prophetic instruction, the Messenger of Allaah, sallallaahu ‘alayhi wa sallam, erected an enclosure around the infected area, and then promised the patient and hopeful, that if they stay put, they will be given the reward of martyrs, while he warned the runaway with ruin and woe. He, sallallaahu ‘alayhi wa sallam said, “The one who flees from the plague is like one who flees from battle. Whoever endures patiently will have the reward of a martyr.” [Ahmad]
Muslims were the only humans who would not flee an epidemic, thus executing the order of their prophet, though not necessarily knowing the wisdom behind it. They became the object of ridicule of nonbelievers due to this behavior, since the healthiest in appearance were considered the most immune. Yet, those who show no outward symptoms while in an infected area are no less likely to be carrying the disease than the visibly ill, as was only discovered in Europe after millions of deaths.