Allah (G. B. H) says: {When you are with them, and stand to lead them in prayer, let one party of them stand up (in prayer) with you, taking their arms with them. When they finish their prostration, let them take their position in the rear and let the other party come up, which have not prayed yet, and let them pray with you, taking all precautions
and bearing arms... } [Al-Nisa': 102]
Also, Allah (G. B. H) says: {If you fear (an enemy), pray on foot, or
riding. }[Al-Baqara: 239]