The LORD said to Joshua, "Don't be afraid or terrified. Take the entire army with you. Start to go up to Ai. Look! I have given the king of Ai, his people, his city, and his land into your power.
References for Joshua 8:1
Do to Ai and its king what you did to Jericho and its king. But you may take its booty and cattle as plunder. Set your ambush behind the city."
So Joshua and the whole army got ready to go up to Ai. Joshua chose thirty thousand brave soldiers. He sent them out by night.
He commanded them, "Look. You are to ambush the city from behind. Don't move too far away from the city. Be ready, all of you.
I will approach the city with all the people. When they come out against us the same way as before, we will flee from them.
They will come out after us until we have drawn them away from the city. They will think, They are fleeing from us as before. So we will flee from them.
But you will rise up from the ambush and take over the city. The LORD your God will give it into your power.
As soon as you seize the city, set it on fire. Act according to the LORD's word. Indeed, I have given you an order!"
Joshua sent them off, and they went to set the ambush. They stayed between Bethel and Ai, to the west of Ai. Joshua spent that night among the people.
Joshua got up early in the morning and mustered the people. Then he and the elders of Israel went up in front of the people to Ai.
The entire army that was with him went up. They moved in close, in front of the city. Then they camped north of Ai, with the valley between them and Ai.
He took about five thousand men and positioned them as an ambush between Bethel and Ai to the west of the city.
The people positioned the main camp on the north side of the city and its rear guard on its west side. That night, Joshua went into the middle of the valley.
As soon as the king of Ai saw this, he and all his troops, the men of the city, hurried out early in the morning to meet Israel in battle. They moved out to the battleground on the slopes down toward the Jordan. He didn't know that there was an ambush set against him behind the city.
References for Joshua 8:14
Then Joshua and all Israel let themselves be beaten before them. They fled in the direction of the desert.
Next, all the troops who were still in the city were called out to chase them. They chased after Joshua and so let themselves be drawn away from the city.
No one who hadn't gone out after Israel was left in either Ai or Bethel. They left the city wide open and chased after Israel.
The LORD said to Joshua, "Point the dagger in your hand toward Ai, because I will give it into your power." So Joshua pointed the dagger in his hand toward the city.
The ambush quickly rose from its place. As soon as he reached out his hand, it charged. They entered the city and captured it. They set the city on fire at once.
Then the men of Ai turned around. They caught sight of the smoke of the city rising toward the sky. They had no chance to flee one way or the other. The troops who were fleeing toward the desert turned against the pursuit.
Joshua and all Israel saw that the ambush had captured the city and that the smoke of the city was rising. So they turned and struck down the men of Ai.
When other Israelites came out of the city to confront them, the men of Ai were caught in the middle. Some Israelites were on one side of them and some on the other. The Israelites struck them down until there was no one left to escape.
But they seized the king of Ai alive and brought him to Joshua.
Israel finished killing the entire population of Ai that had chased them out into the open wasteland. All of them were finished off without mercy. Then all Israel went back to Ai and struck it down without mercy.
Twelve thousand men and women died that day, all the people of Ai.
Joshua didn't pull back the hand that was stretched out holding a dagger until he had wiped out the whole population of Ai as something reserved for God.
However, Israel did take the cattle and other booty of that city as plunder for themselves, in agreement with the command that the LORD had given Joshua.
Then Joshua burned Ai. He made it a permanently deserted mound. That is still the case today.
He hanged the king of Ai on a tree until evening. At sundown, Joshua gave an order, and they took his body down from the tree. They threw it down at the opening of the city gate. Then they raised over it a great pile of stones that is still there today.