The scholars are all in agreement about the legality of “fear prayer” (salatul Khauf). The Qur’an says: “When You (O Prophet) 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 prostrations, let them take their position in the rear. And let the other party come up which has not yet prayed – and let them pray with you, taking all precautions, and bearing arms: the unbelievers wish if you were negligent of your arms and your baggage, to assault you in a single rush. But there is no blame on you if you put away your arms because of the inconvenience of rain or because you are ill; but take (every) precaution for yourselves. For the unbelievers Allah has prepared humiliating punishment.”
On this subject Imam Ahmad says: “There are six or seven confirmed hadith about ‘salatul khauf,’ and whichever way one performs it, it will be valid.”
Ibn al-Qayyim says: “Basically, there are six ways to pray salatal khauf, although some say there are more than (six ways of praying it). Whenever they notice any difference in the narration of an incident, they describe it as a difference [in the manner of prayer] thus coming to seventeen ways. This might be due to different acts of the Prophet or simply to differences in the narrations.” Al-Hafiz says: “This is the true position and its explanation is given below.