The Holy Prophet was asked about the amulets used for seeking a cure, (Ghazzali reports that the question was about both the spell and the medicine) whether they could forestall a divinely ordained destiny. In reply the Prophet said that they themselves were a part of destiny (Bihar al-Anwar). He meant to say that their healing effect was also divinely ordained.
Imam Ali (a) was sitting under the shade of a bent wall. He moved from that place and went to another wall. Someone said to him: “O Commander of the Faithful! Do you flee from a divinely ordained destiny?”. He said: “Yes, I feel from one destiny to another” (Tawhid by Shaikh Sadduq). In other words, he said that if he sat under a dilapidated wall and it fell on him, that would be in accordance with a divinely ordained destiny, for it is within the normal course of a sequence of causes and effects that a man sitting under a tottering wall should suffer. Similarly it was also in accordance with a divinely ordained destiny that he should be safe, if he moved away.
It is possible that in the course of another sequence of cause and effect, the same person may be confronted with some other danger. If that happens, that also will be in accordance with a divinely ordained fate and destiny.
Anyway, to keep oneself away from a danger amounts to fleeing from one divinely ordained destiny to another.
History of Islam on the whole indicates that the Muslims of early era had a firm belief in fate and destiny. They did not see any inconsistency between their being masters of their own destiny and their belief in this doctrine. They considered it to be an indisputable fact that not only destiny was changeable but also that all changes were a part of an overall destiny. They had a firm belief in destiny, but never believed in compulsion or predestination. Therefore they did not become lethargic and insensitive nor did they leave anything to their fate. They always asked Allah for the best destiny, because they knew that various destinies existed in every case.
It may look surprising that they asked for the best destiny but not the best of what had been destined, as is borne out by the wordings of their prayer. It is all the more surprising that even the simple-minded Muslims were conscious of this subtle difference.
Ibn Abi al-Hadid in his commentary on the Nahjal-Balaghah says: ‘While on his way to Syria Umar ibn al-Khattab received a report that plague had broken out there. He consulted his companions whether he should visit the affected town. Most of them advised him not to take this risk. But Abu Ubaydah ibn al-Jarrah said: “O Commander of the Faithful! Do you flee from a divinely ordained destiny?” “Yes, I flee from one divinely ordained destiny to another”, said Umar. At this stage a man claimed that he had heard the Prophet saying: “Do not enter a town where plague is raging. But if you are already in it, do not leave it”. Umar, who was somewhat hesitant before hearing this hadith, decided not to visit the place.’
The Shi’ah and the Sunni reports on the whole indicate that the Holy Prophet (s) raised the question of fate and destiny before his companions. Similarly Imam Ali (a) on several occasions talked about it. It is remarkable that they dealt with this question with such a skill that it did not lead the early Muslims to predestinarianism, nor did it shake their self-confidence. The reports of their sayings and doings which have reached us, clearly bear out this fact. Later when the Muslim scholastic theologians started discussing and analyzing this question, they could not distinguish between a belief in destiny and in predestinarianism. Since then the confusion is continuing with a result that a belief during the past fourteen centuries, very few scholars have been able to make a clear distinction between the two doctrines.