First and last post from Kitaab Salat-ul-Khawf [Book of Fear Prayer].
Volume 2, Book 14, Number 762:
I asked Az-Zuhri, “Did the Prophet ever offer the Fear Prayer?” Az-Zuhri said, “I was told by Salim that ‘Abdullah bin Umar had said, ‘I took part in a holy battle with Allah’s Apostle in Najd. We faced the enemy and arranged ourselves in rows. Then Allah’s Apostle (p.b.u.h) stood up to lead the prayer and one party stood to pray with him while the other faced the enemy. Allah’s Apostle (p.b.u.h) and the former party bowed and performed two prostrations. Then that party left and took the place of those who had not prayed. Allah’s Apostle prayed one Raka (with the latter) and performed two prostrations and finished his prayer with Taslim. Then everyone of them bowed once and performed two prostrations individually.’ “
Volume 2, Book 14, Number 763:
Ibn Umar said something similar to Mujahid’s saying: Whenever (Muslims and non-Muslims) stand face to face in battle, the Muslims can pray while standing. Ibn Umar added, “The Prophet said, ‘If the number of the enemy is greater than the Muslims, they can pray while standing or riding (individually).’ “
Volume 2, Book 14, Number 764:
Narrated Ibn Abbas:
Once the Prophet (p.b.u.h) led the fear prayer and the people stood behind him. He said Takbir (Allahu-Akbar) and the people said the same. He bowed and some of them bowed. Then he prostrated and they also prostrated. Then he stood for the second Raka and those who had prayed the first Raka left and guarded their brothers. The second party joined him and performed bowing and prostration with him. All the people were in prayer but they were guarding one another during the prayer.
Volume 2, Book 14, Number 765:
Narrated Jabir bin ‘Abdullah:
On the day of the Khandaq Umar came, cursing the disbelievers of Quraish and said, “O Allah’s Apostle! I have not offered the ‘Asr prayer and the sun has set.” The Prophet replied, “By Allah! I too, have not offered the prayer yet. “The Prophet then went to Buthan, performed ablution and performed the ‘Asr prayer after the sun had set and then offered the Maghrib prayer after it.”
Volume 2, Book 14, Number 766:
Narrated Anas bin Malik:
Allah’s Apostle (p.b.u.h) offered the Fajr prayer when it was still dark, then he rode and said, ‘Allah Akbar! Khaibar is ruined. When we approach near to a nation, the most unfortunate is the morning of those who have been warned.” The people came out into the streets saying, “Muhammad and his army.” Allah’s Apostle vanquished them by force and their warriors were killed; the children and women were taken as captives. Safiya was taken by Dihya Al-Kalbi and later she belonged to Allah’s Apostle go who married her and her Mahr was her manumission.
Salat-ul-Khwaf or the Prayer of Fear or the Supererogatory Prayer is offered during times of fear and danger. Prophet (SAW) is reported to have prayed it during times of battle. Allah talks about it in the Qur’an:
And when you (Muslims) travel in the land, there is no sin on you if you shorten As-Salat (the prayer) if you fear that the disbelievers may put you in trial (attack you etc.), verily, the disbelievers are ever unto you open enemies.
When you (O Messenger Muhammad صلى الله عليه وسلم) are among them, and lead them in As-Salat (the prayer), let one party of them stand up [in Salat (prayer)] with you taking their arms with them; when they finish their prostrations, let them take their positions in the rear and let the other party come up which have not yet prayed, and let them pray with you taking all the precautions and bearing arms. Those who disbelieve wish, if you were negligent of your arms and your baggage, to attack you in a single rush, but there is no sin 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. Verily, Allah has prepared a humiliating torment for the disbelievers.
[An-Nisa: 101 – 102]
Ibn Kathir says in his Tafsir:
The Fear prayer has different forms, for the enemy is sometimes in the direction of the Qiblah and sometimes in another direction. The Fear prayer consists sometimes of four Rak`ahs, three Rak`ahs, as for Maghrib, and sometimes two Rak`ah like Fajr and prayer during travel. The Fear prayer is sometimes prayed in congregation, but when the battle is raging, congregational prayer may not be possible. In this case, they pray each by himself, facing the Qiblah or otherwise, riding or on foot. In this situation, they are allowed to walk and fight, all the while performing the acts of the prayer. Some scholars said that in the latter case, they pray only one Rak`ah, for Ibn `Abbas narrated, “By the words of your Prophet , Allah has ordained the prayer of four Rak`ah while residing, two Rak`ah during travel, and one Rak`ah during fear.” Muslim, Abu Dawud, An-Nasa’i and Ibn Majah recorded it. This is also the view of Ahmad bin Hanbal. Al-Mundhiri said, “This is the saying of `Ata’, Jabir, Al-Hasan, Mujahid, Al-Hakam, Qatadah and Hammad; and Tawus and Ad-Dahhak also prefered it.” Abu `Asim Al-`Abadi mentioned that Muhammad bin Nasr Al-Marwazi said the Fajr prayer also becomes one Rak`ah during fear. This is also the opinion of Ibn Hazm. Ishaq bin Rahwayh said, “When a battle is raging, one Rak`ah during which you nod your head is sufficient for you. If you are unable, then one prostration is sufficient, because the prostration is remembrance of Allah.”
And some interesting background given in the Tafsir of Ibn Kathir. Do read!