Then the LORD said to Joshua, "Do not be afraid or discouraged. Take the entire army and attack Ai, for I have given to you the king of Ai, his people, his city, and his land.
You will destroy them as you destroyed Jericho and its king. But this time you may keep the captured goods and the cattle for yourselves. Set an ambush behind the city."
So Joshua and the army of Israel set out to attack Ai. Joshua chose thirty thousand fighting men and sent them out at night
with these orders: "Hide in ambush close behind the city and be ready for action.
When our main army attacks, the men of Ai will come out to fight as they did before, and we will run away from them.
We will let them chase us until they have all left the city. For they will say, 'The Israelites are running away from us as they did before.'
Then you will jump up from your ambush and take possession of the city, for the LORD your God will give it to you.
Set the city on fire, as the LORD has commanded. You have your orders."
So they left that night and lay in ambush between Bethel and the west side of Ai. But Joshua remained among the people in the camp that night.
Early the next morning Joshua roused his men and started toward Ai, accompanied by the leaders of Israel.
They camped on the north side of Ai, with a valley between them and the city.
That night Joshua sent five thousand men to lie in ambush between Bethel and Ai, on the west side of the city.
So they stationed the main army north of the city and the ambush west of the city. Joshua himself spent that night in the valley.
When the king of Ai saw the Israelites across the valley, he and all his army hurriedly went out early the next morning and attacked the Israelites at a place overlooking the Jordan Valley. But he didn't realize there was an ambush behind the city.
References for Joshua 8:14
Joshua and the Israelite army fled toward the wilderness as though they were badly beaten,
and all the men in the city were called out to chase after them. In this way, they were lured away from the city.
There was not a man left in Ai or Bethel who did not chase after the Israelites, and the city was left wide open.
References for Joshua 8:17
Then the LORD said to Joshua, "Point your spear toward Ai, for I will give you the city." Joshua did as he was commanded.
As soon as Joshua gave the signal, the men in ambush jumped up and poured into the city. They quickly captured it and set it on fire.
When the men of Ai looked behind them, smoke from the city was filling the sky, and they had nowhere to go. For the Israelites who had fled in the direction of the wilderness now turned on their pursuers.
When Joshua and the other Israelites saw that the ambush had succeeded and that smoke was rising from the city, they turned and attacked the men of Ai.
Then the Israelites who were inside the city came out and started killing the enemy from the rear. So the men of Ai were caught in a trap, and all of them died. Not a single person survived or escaped.
Only the king of Ai was taken alive and brought to Joshua.
When the Israelite army finished killing all the men outside the city, they went back and finished off everyone inside.
So the entire population of Ai was wiped out that day -- twelve thousand in all.
For Joshua kept holding out his spear until everyone who had lived in Ai was completely destroyed.
References for Joshua 8:26
Only the cattle and the treasures of the city were not destroyed, for the Israelites kept these for themselves, as the LORD had commanded Joshua.
So Ai became a permanent mound of ruins, desolate to this very day.
References for Joshua 8:28
Joshua hung the king of Ai on a tree and left him there until evening. At sunset the Israelites took down the body and threw it in front of the city gate. They piled a great heap of stones over him that can still be seen today.