During the battle, the five kings escaped and hid in a cave at Makkedah.
When Joshua heard that they had been found,
he issued this command: "Cover the opening of the cave with large rocks and place guards at the entrance to keep the kings inside.
The rest of you continue chasing the enemy and cut them down from the rear. Don't let them get back to their cities, for the LORD your God has given you victory over them."
So Joshua and the Israelite army continued the slaughter and wiped out the five armies except for a tiny remnant that managed to reach their fortified cities.
Then the Israelites returned safely to their camp at Makkedah. After that, no one dared to speak a word against Israel.
Then Joshua said, "Remove the rocks covering the opening of the cave and bring the five kings to me."
So they brought the five kings out of the cave -- the kings of Jerusalem, Hebron, Jarmuth, Lachish, and Eglon.
Joshua told the captains of his army, "Come and put your feet on the kings' necks." And they did as they were told.
"Don't ever be afraid or discouraged," Joshua told his men. "Be strong and courageous, for the LORD is going to do this to all of your enemies."
Then Joshua killed each of the five kings and hung them on five trees until evening.
As the sun was going down, Joshua gave instructions for the bodies of the kings to be taken down from the trees and thrown into the cave where they had been hiding. Then they covered the opening of the cave with a large pile of stones, which remains to this very day.
That same day Joshua completely destroyed the city of Makkedah, killing everyone in it, including the king. Not one person in the city was left alive. He killed the king of Makkedah as he had killed the king of Jericho.
Then Joshua and the Israelites went to Libnah and attacked it.
There, too, the LORD gave them the city and its king. They slaughtered everyone in the city and left no survivors. Then Joshua killed the king of Libnah just as he had killed the king of Jericho.
From Libnah, Joshua and the Israelites went to Lachish and attacked it.
And the LORD gave it to them on the second day. Here, too, the entire population was slaughtered, just as at Libnah.
During the attack on Lachish, King Horam of Gezer had arrived with his army to help defend the city. But Joshua's men killed him and destroyed his entire army.
Then Joshua and the Israelite army went to Eglon and attacked it.
They captured it in one day, and as at Lachish, they completely destroyed everyone in the city.
After leaving Eglon, they attacked Hebron,
capturing it and all of its surrounding towns. And just as they had done at Eglon, they completely destroyed the entire population. Not one person was left alive.
Then they turned back and attacked Debir.
They captured the city, its king, and all of its surrounding villages. And they killed everyone in it, leaving no survivors. They completely destroyed Debir just as they had destroyed Libnah and Hebron.
So Joshua conquered the whole region -- the kings and people of the hill country, the Negev, the western foothills, and the mountain slopes. He completely destroyed everyone in the land, leaving no survivors, just as the LORD, the God of Israel, had commanded.
References for Joshua 10:40
Joshua slaughtered them from Kadesh-barnea to Gaza and from Goshen to Gibeon.
In a single campaign Joshua conquered all these kings and their land, for the LORD, the God of Israel, was fighting for his people.
Then Joshua and the Israelite army returned to their camp at Gilgal.