The Messenger of Allah ﷺ mentioned several hadiths, among them this one. The Messenger of Allah ﷺ said, "One of the prophets went out on a military campaign and said to his people, 'Let no man follow me who has married a woman and wishes to consummate the marriage but has not yet done so, nor any man who has built a house but has not yet raised its roof, nor any man who has bought sheep or pregnant she-camels and is waiting for them to give birth.'So he went out on the campaign and drew near to the town around the time of the afternoon prayer, or close to it. He said to the sun, 'You are under command and I am under command. O Allah, hold it back for me a while.' So it was held back for him until Allah granted him victory.They gathered the spoils, and the fire came forward to consume them but refused to touch them. He said, 'There is misappropriation among you. Let one man from each tribe pledge allegiance to me.' They pledged allegiance, and one man's hand stuck to his hand. He said, 'The misappropriation is among you. Let your tribe pledge allegiance to me.' They pledged, and the hands of two or three men stuck to his. He said, 'The misappropriation is among you. You have stolen from the spoils.'So they brought out for him something like the head of a cow made of gold. They placed it among the spoils on the open ground, and the fire came forward and consumed them. Spoils were not lawful for anyone before us. That is because Allah saw our weakness and inability, so He made them lawful for us."
عن رسول الله ﷺ فذكر أحاديث منها: قال رسول الله ﷺ: غزا نبي من الأنبياء، فقال لقومه: لا يتبعني رجل قد ملك بضع امرأة، وهو يريد أن يبني بها، ولما يبن، ولا آخر قد بنى بنيانا، ولما يرفع سقفها، ولا آخر قد اشترى غنما أو خلفات، وهو منتظر ولادها قال: فغزا فأدنى للقرية حين صلاة العصر، أو قريبا من ذلك، فقال للشمس: أنت مأمورة وأنا مأمور، اللهم احبسها علي شيئا فحبست عليه حتى فتح الله عليه. قال: فجمعوا ما غنموا. فأقبلت النار لتأكله، فأبت أن تطعمه، فقال: فيكم غلول، فليبايعني من كل قبيلة رجل، فبايعوه، فلصقت يد رجل بيده، فقال: فيكم الغلول. فلتبايعني قبيلتك، فبايعته قال: فلصقت بيد رجلين أو ثلاثة، فقال: فيكم الغلول، أنتم غللتم، قال: فأخرجوا له مثل رأس بقرة من ذهب، قال: فوضعوه في المال وهو بالصعيد، فأقبلت النار فأكلته، فلم تحل الغنائم لأحد من قبلنا، ذلك بأن الله تبارك وتعالى رأى ضعفنا وعجزنا، فطيبها لنا.
Bukhari narrated it in the chapter on the obligation of khumus (3124), and Muslim in the chapter on jihad and expeditions (1747), both by the route of Ibn Mubarak, from Mamar, from Hammam bin Munabbih, from Abu Hurairah, who related it. The wording given here is that of Muslim.Yusha bin Nun was a prophet among the prophets of Banu Israil, and the successor of Musa after his death. He was one of the leaders of the tribe of Yusuf
, who numbered forty thousand five hundred people. He was the one who led Banu Israil out of the tent after the death of Musa
, heading with them toward Bayt al-Maqdis. He crossed the Jordan River and arrived at the city of Jericho, which was among the most fortified cities in its walls, the loftiest in its palaces, and the most populous in its inhabitants. He besieged it for six months, then conquered it. It is said that the sun was held back for him during his siege of the city of Jericho, and it is also said that this happened during the conquest of Bayt al-Maqdis. And Allah knows best.See Bidayah wa Nihayah (2/235-236).