وَمَن يُوَلِّهِمْ يَوْمَيِذٍ دُبُرَهُ إِلاَّ مُتَحَرِّفاً لِّقِتَالٍ
And whoever turns his back to them on such a day -- unless it be a stratagem of war...
The Ayah says, whoever flees from the enemy by way of planning to pretend that he is afraid of the enemy, so that they follow him and he takes the chance and returns to kill the enemy, then there is no sin on him.
This is the explanation of Sa`id bin Jubayr and As-Suddi.
Ad-Dahhak also commented,
"Whoever went ahead of his fellow Muslims to investigate the strength of the enemy and make use of it,
أَوْ مُتَحَيِّزاً إِلَى فِيَةٍ
(or to retreat to a troop (of his own)),
meaning he leaves from here to another troop of Muslims to assist them or be assisted by them. So that is allowed for him, or even during the battle if he flees from his brigade to the commander. Or going to the grand Imam, would also fall under this permission."
Umar bin Al-Khattab, may Allah be pleased with him, said about Abu Ubayd when he was fighting on the bridge in the land of the Persians, because of the many Zoroastrian soldiers,
"If he retreated to me then I would be as a troop for him."
This is how it was reported by Muhammad bin Sirin from Umar.
In the report of Abu Uthman An-Nahdi from Umar, he said;
When Abu Ubayd was fighting, Umar said, "O people! We are your troop."
Mujahid said that Umar said,
"We are the troop of every Muslim."
Abdul-Malik bin Umayr reported from Umar,
"O people! Don't be confused over this Ayah, it was only about the day of Badr, and we are a troop for every Muslim."
Ibn Abi Hatim (recorded) that Nafi` questioned Ibn Umar,
"We are people who are not stationary when fighting our enemy, and we may not know where our troop is, be it that of our Imam or our army."
So he replied, "The troop is Allah's Messenger."
I said but Allah said,
إِذَا لَقِيتُمُ الَّذِينَ كَفَرُواْ زَحْفاً
(when you meet those who disbelieve in the battlefield) to the end of the Ayah. So he said;
"This Ayah was about Badr, not before it nor after it."
Ad-Dahhak commented that Allah's statement,
أَوْ مُتَحَيِّزاً إِلَى فِيَةٍ
or to retreat to a troop,
refers to "Those who retreat to the Messenger of Allah and his Companions (when the Messenger was alive), and those who retreat in the present time to his commander or companions."
However, if one flees for any other reason than those mentioned here, then it is prohibited and considered a major sin.
Al-Bukhari and Muslim recorded that Abu Hurayrah said that the Messenger of Allah said,
اِجْتَنِبُوا السَّبْعَ الْمُوبِقَات
"Shun the seven great destructive sins."
The people inquired, "O Allah's Messenger! What are they?"
He said,
الشِّرْكُ بِاللهِ
وَالسِّحْرُ
وَقَتْلُ النَّفْسِ الَّتِي حَرَّمَ اللهُ إِلاَّ بِالْحَقِّ
وَأَكْلُ الرِّبَا
وَأَكْلُ مَالِ الْيَتِيمِ
وَالتَّوَلِّي يَوْمَ الزَّحْفِ
وَقَذْفُ الْمُحْصَنَاتِ الْغَافِلَتِ الْمُوْمِنَات
They are;
Joining others in worship with Allah,
magic,
taking life which Allah has forbidden, except for a just cause (according to Islamic law),
consuming Riba,
consuming an orphan's wealth,
fleeing the battlefield at the time of fighting,
and false accusation to chaste women, who never even think of anything touching chastity and are good believers.
This is why Allah said here,
فَقَدْ بَاء
he indeed has drawn upon himself...,
and returned with,
بِغَضَبٍ مِّنَ اللّهِ وَمَأْوَاهُ
wrath from Allah. And his abode...,
destination, and dwelling place on the Day of Return,
جَهَنَّمُ وَبِيْسَ الْمَصِيرُ
is Hell, and worst indeed is that destination