Musnad Ahmad
It was narrated that ‘Ali (رضي الله عنه) said: I remember us on the night of Badr, there was no one among us who was not sleeping, except the Messenger of Allah (ﷺ) who prayed facing a tree and offered supplication until morning came, and there was no horseman among us on the day of Badr except Al-Miqdad bin Al-Aswad.
حَدَّثَنَا مُحَمَّدُ بْنُ جَعْفَرٍ، حَدَّثَنَا شُعْبَةُ، عَنْ أَبِي إِسْحَاقَ، قَالَ سَمِعْتُ حَارِثَةَ بْنَ مُضَرِّبٍ، يُحَدِّثُ عَنْ عَلِيٍّ، رَضِيَ اللَّهُ عَنْهُ قَالَ لَقَدْ رَأَيْتُنَا لَيْلَةَ بَدْرٍ وَمَا مِنَّا إِنْسَانٌ إِلَّا نَائِمٌ إِلَّا رَسُولَ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ فَإِنَّهُ كَانَ يُصَلِّي إِلَى شَجَرَةٍ وَيَدْعُو حَتَّى أَصْبَحَ وَمَا كَانَ مِنَّا فَارِسٌ يَوْمَ بَدْرٍ غَيْرَ الْمِقْدَادِ بْنِ الْأَسْوَدِ.
Grade: Sahih (Darussalam)] (Darussalam)
Reference