وَالرُّخْصَةِ لِلطَّائِفَةِ الْأُولَى فِي تَرْكِ اسْتِقْبَالِهَا الْقِبْلَةَ بَعْدَ فَرَاغِهَا مِنَ الرَّكْعَةِ الْأُولَى لِتَحْرُسَ الطَّائِفَةَ الثَّانِيَةَ مِنَ الْعَدُوِّ وَقَضَاءِ الطَّائِفَتَيْنِ الرَّكْعَةَ الثَّانِيَةَ بَعْدَ تَسْلِيمِ الْإِمَامِ
So, after the first group has finished the first rak‘ah, the second group is permitted to abandon facing the qiblah in order to protect against the enemy—and the explanation of both groups completing the second rak‘ah after the imam has said the salām.