Sura Aal-i-Imraan

3:127

لِيَقْطَعَ طَرَفًۭا مِّنَ ٱلَّذِينَ كَفَرُوٓا۟ أَوْ يَكْبِتَهُمْ فَيَنقَلِبُوا۟ خَآئِبِينَ

[och] för att låta några av sanningens förnekare smaka döden eller nederlagets förödmjukelse och se sina förhoppningar grusas.

Tafsir 3:127

Your victory in the Battle of Badr was because Allah willed that a group of the disbelievers be destroyed, and another be humiliated, frustrating them through defeat so that they withdrew.