Summary: Five Amorite kings gathered to attack the Gibeonites, who had previously made a pact with Joshua and the Jewish people. Joshua fought the belligerent Amorites and beat them into retreat. Yavin king of Chatzor also gathered a huge army to fight Joshua but were defeated following a pre-emptive strike.
In depth: As Joshua is fighting the five Amorite armies, he commands the sun and moon to stop in order to complete the battle. According to Rabbi Eliezer ben Hyrcanus (d. 118CE) it was Friday afternoon so Joshua entreated God to delay the onset of Shabbat in order to complete the battle. If so, why did Joshua also command the moon to stop? Rabbi David ben Solomon ibn Zimra (Radbaz, 16th Century) explained that this was to prevent a solar eclipse. Why is this significant?
Many of our ancient texts contain references to the celestial bodies and their movements which are difficult to reconcile with scientific reality. The Midrash records that the sun exits through a window in the sky during the night which is why its light does not penetrate at night time (Exodus Rabbah 15). Similarly, in the Shabbat morning service we describe God as the One Who “cleaves the windows of the sky, Who brings the sun out of its place and the moon from its abode” (Green Siddur page 373).
Rabbi Chaim Moshe Luzzato (Ramchal, d. 1746) explained that when the sages employed references to celestial bodies, they were not necessarily referring to their physical reality, but employed them as metaphors for metaphysical phenomena.
Rabbi Naftali Tvi Yehudah Berlin (Netziv, d. 1893) explains that the sun refers to the flow of God’s positive influence and blessing, emanating from the heavens down to earth. The physical sun provides just enough light and warmth to allow life to flourish. So too God’s positive influence supplies the perfect balance of spiritual impact in this world.
Joshua wanted to prevent both the sun from setting and a solar eclipse in order to reinforce the message which has been a theme throughout this book; victory was dependent on God’s power and authority, not solely on the physical might of the army.