Sayyiduna Jabir bin Abdullah (may Allah be pleased with them both) says: We went out with the Messenger of Allah (peace and blessings be upon him) on the campaign of Dhat al-Riqa'. He mentioned the hadith, and said: The Messenger of Allah (peace and blessings be upon him) camped at a place and said: "Who will guard us tonight?" One man from the Muhajirun and one from the Ansar volunteered. They both said: "O Messenger of Allah (peace and blessings be upon him), we (will)." He (peace and blessings be upon him) said: "Then both of you stay at the mouth of the valley." When the two of them reached the valley, the Ansari said to the Muhajir: "Which part of the night would you prefer me to keep guard for you, the first part or the last?" He said: "Keep guard for me in the first part of the night." So the Muhajir lay down and slept, while the Ansari stood up to pray. Then he mentioned the (rest of the) hadith.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب السير / 18448