Do not grieve; indeed Allah is with us.
“Do not grieve; indeed Allah is with us.”
If you O believers, do not help the Messenger (peace be upon him) and respond to his call to strive for the sake of Allah, then Allah has already helped him when you were not with him;
The plain meaning, from Al-Mukhtasar fi at-Tafsir
إِلَّا تَنصُرُوهُ فَقَدْ نَصَرَهُ ٱللَّهُ إِذْ أَخْرَجَهُ ٱلَّذِينَ كَفَرُوا۟ ثَانِىَ ٱثْنَيْنِ إِذْ هُمَا فِى ٱلْغَارِ إِذْ يَقُولُ لِصَٰحِبِهِۦ لَا تَحْزَنْ إِنَّ ٱللَّهَ مَعَنَا ۖ فَأَنزَلَ ٱللَّهُ سَكِينَتَهُۥ عَلَيْهِ وَأَيَّدَهُۥ بِجُنُودٍ لَّمْ تَرَوْهَا وَجَعَلَ كَلِمَةَ ٱلَّذِينَ كَفَرُوا۟ ٱلسُّفْلَىٰ ۗ وَكَلِمَةُ ٱللَّهِ هِىَ ٱلْعُلْيَا ۗ وَٱللَّهُ عَزِيزٌ حَكِيمٌ
If you do not aid him i.e., the Prophet (ﷺ) - Allah has already aided him when those who disbelieved had driven him out of Makkah as one of two, when they were in the cave and he i.e., Muḥammad (ﷺ) said to his companion, "Do not grieve; indeed Allah is with us." And Allah sent down His tranquility upon him and supported him with soldiers i.e., angels you did not see and made the word of those who disbelieved the lowest, while the word of Allah - that is the highest. And Allah is Exalted in Might and Wise.
What does Quran 9:40 mean?
These words were said in the cave of Thawr. The Prophet (peace be upon him) and Abu Bakr were hiding from the men of Quraysh who had driven them out of Makkah and were close enough to be heard; Abu Bakr was afraid they would be found. The reassurance he was given claims nothing about the odds. It only says who is present — and the verse continues that Allah sent down tranquillity, and armies no one could see.
Written from Al-Mukhtasar fi at-Tafsir