The Battle of the Long Day took place during the conquest of Canaan when the Israelites fought against the Canaanite armies of five kings. This battle was the result of five Canaanite city/states joining together in an alliance to fight the city of Gibeon for creating a treaty with the Israelites. When the people of Gibeon saw the armies coming, they sent word to Israelites who came to their rescue. As the sun was about to go down, Joshua asked God to keep the sun and moon still, which resulted in the day being extended about twelve hours.
When the kings in the land of Canaan heard about the destruction of Jericho and Ai, they came together to wage war against the Israelites. However, the people of the important city of Gibeon resorted to a ruse instead of an attack. They prepared some provisions ad loaded their donkeys with worn out sacks and old wineskins that were cracked and mended. They wore worn and patched sandals and old clothes. They brought with them dry and moldy bread among their food supply.
Looking like and claiming that they came from a far away land (although they were very close to the Israelites), they went to Israel's leader Joshua in the Israelite camp and requested to make a treaty with them. The Israelites questioned them and were fooled by their ruse, and they did not inquire of the LORD to see if these men were telling the truth. Thus Joshua made a peace treaty with them so that they may live, and the treaty was ratified by the leaders of the assembly by oath.
Three days later, the Israelites discovered the truth — the Gibeonites were actually nearby neighbors. So the Israelites set out and came to their cities but did not attack them because the leaders of the assembly had sworn an oath to the Gibeonites by the LORD. Because of this, the Israelites grumbled against the leaders, who answered by reaffirming to the Israelites the oath they had made and that they could not harm them. Yet they decided to make them be the woodcutters and water carriers in the service of the whole assembly, thus keeping their promise not to harm them.
Joshua questioned the Gibeonites about their deception and said they were under a curse because of it, telling them what the leaders had decided to do with them. The Gibeonites replied by saying they had deceived them because they had heard of the victories of the Israelites and that they feared for their lives. They submitted themselves to the Israelites and allowed them to do whatever seemed good and right to to them. Thus, the Gibeonites became the woodcutters and water carriers for the Israelites and to provide for the needs of the LORD's altar; and they still did this when the book of Joshua was put into writing.
When Adoni-Zedek, the king of Jerusalem, heard about the destruction of both Jericho and Ai and the treaty between the Israelites and Gibeon, he and his people were very alarmed by this, since Gibeon was an important city, compared with one of the royal cities. The city of Gibeon was larger than Ai and every man in it were very good fighters. Adoni-Zedek asked Hoham the king of Hebron, Piram the king of Jarmuth, Japhia the king of Lachish and Debir the king of Eglon to help him attack Gibeon because it made peace with the Israelites. They agreed and the five kings joined forces. They took up positions against the city of Gibeon and attacked it.
The Gibeonites sent word to Joshua in the Israelite camp that was at Gilgal, asking him to save them from the five kings. Joshua responded by marching up from Gilgal with his entire army, including all of the best fighting men. The LORD reassured Joshua by telling him that He gave the army of the five kings into Joshua's hand and that they wouldn't be able to stand against the Israelites. The march to Gibeon lasted all night, and the Israelites took the attacking army by surprise.
The LORD threw the army into confusion before Israel so Joshua and the Israelites completely defeated them at Gibeon. Israel pursued the army along the road that went up to Beth Horon and cut them down all the way to Azekah and Makkedah. During their flight, the LORD hurled large hailstones down on them, which killed more of them than the Israelites themselves killed.
The Sun and Moon Stood Still
When Joshua realized that they needed more daylight to finish off the army, he prayed to the LORD and commanded the sun and moon to stop. The sun stood still over Gibeon where it was setting, and the moon over the valley of Aijalon. This was recorded in the book of Jasher along with the book of Joshua. The sun stopped in the sky and delayed setting for almost a full day, about 12 hours. This miraculous event allowed the Israelites to finish fighting the army and even capture and destroy cities of Makkedah, Libnah, Lachish, Eglon, Hebron and even Debir. They eventually captured the whole region and totally destroyed everyone, as the LORD had commanded.
The End of the Kings
During the battle, the five kings had fled and hid in a certain cave at Makkedah. Joshua heard of it and ordered for large rocks to be rolled up to the mouth of the cave, trapping the kings. Men were posted there to guard it. When Joshua and the Israelites defeated the army completely, they returned safely to the camp at Makkedah. Then Joshua ordered that the mouth of the cave be opened and the kings be brought out to him. He had his commanders with him to put their feet on the necks of the kings. Joshua told the commanders not to be afraid nor discouraged for the LORD would do to Israel's enemies what he was about to do to the kings. After speaking to the commanders, he put the kings to death and exposed their bodies on five poles until evening came. At sunset Joshua ordered that the bodies be brought down and thrown in the cave the kings had hidden in. Large rocks were placed at the mouth of the cave and were still there when the book of Joshua was put into writing.