(Allah hath promised such of you as believe and do good work…) [24:55]. Al-Rabi' ibn Anas related that Abu'l-'Aliyah said regarding this verse: “The Messenger of Allah, Allah bless him and give him peace, and his Companions remained in Mecca, after the advent of the revelation, for ten years in a state of fear: sleeping at night and waking in the morning with weapons at their sides. Then the Prophet was commanded to migrate to Medina. One of his Companions asked him: 'O Messenger of Allah, there is not a single day in which we feel safe such that we can put down our weapons'. The Messenger of Allah, Allah bless him and give him peace, said: 'It will not be long before one of you will be sitting unarmed amidst huge numbers of people, none of whom carries a weapon'. Then, Allah, exalted is He, revealed (Allah hath promised such of you as believe and do good work…) up to the end of the verse. Consequently, Allah, exalted is He, enabled His Prophet, Allah bless him and give him peace, to have the upper hand over the Arabian peninsula, and the Muslims were able to put down their weapons and feel safe. They remained safe after Allah, exalted is He, took to Himself His Prophet, and during the reign of Abu Bakr, 'Umar and 'Uthman, may Allah be well pleased with them. When they fell into that which they fell and were ungrateful, Allah brought fear into their hearts; they changed and so Allah, exalted is He, changed what they had”. Isma'il ibn al-Hasan ibn Muhammad ibn al-Husayn al-Naqib informed us> his grandfather> 'Abd Allah ibn Muhammad ibn al-Hasan al-Nasrabadhi> Ahmad ibn Sa'id al-Darimi> 'Ali ibn al-Husayn ibn Waqid> his father> al-Rabi' ibn Anas> Abu'l-'Aliyah>> Ubayy ibn Ka'b who said: “When the Messenger of Allah, Allah bless him and give him peace, and his Companions migrated to Medina and the Helpers sheltered them, all the Arabs united to destroy them, such that they were forced to sleep with their weapon and wake up with their weapons. Some said: 'Do you think we will live to see the day when we go to sleep fearing no one but Allah, glorified and majestic is He?' [As a response] Allah, exalted is He, revealed (Allah hath promised such of you as believe and do good work) up to His words (Those who disbelieve henceforth, they are the miscreants) i.e. those who are ungrateful for [Allah's] bounties”. This was narrated by al-Hakim Abu 'Abd Allah in his Sahih from Muhammad ibn Salih ibn Hani'> Abu Sa'id ibn Shadhan> al-Darimi.
Asbab Al-Nuzul by Al-Wahidi , trans. Mokrane Guezzou