The Lord said to Joshua, "Take all the soldiers with you and go on up to Ai. Don't be afraid or discouraged. I will give you victory over the king of Ai; his people, city, and land will be yours.
You are to do to Ai and its king what you did to Jericho and its king, but this time you may keep its goods and livestock for yourselves. Prepare to attack the city by surprise from the rear."
So Joshua got ready to go to Ai with all his soldiers. He picked out thirty thousand of his best troops and sent them out at night
with these orders: "Hide on the other side of the city, but not too far away from it; be ready to attack.
My men and I will approach the city. When the men of Ai come out against us, we will turn and run, just as we did the first time.
They will pursue us until we have led them away from the city. They will think that we are running from them, as we did before.
Then you will come out of hiding and capture the city. The Lord your God will give it to you.
After you have taken the city, set it on fire, just as the Lord has commanded. These are your orders."
So Joshua sent them out, and they went to their hiding place and waited there, west of Ai, between Ai and Bethel. Joshua spent the night in camp.
Early in the morning Joshua got up and called the soldiers together. Then he and the leaders of Israel led them to Ai.
The soldiers with him went toward the main entrance to the city and set up camp on the north side, with a valley between themselves and Ai.
He took about five thousand men and put them in hiding west of the city, between Ai and Bethel.
The soldiers were arranged for battle with the main camp north of the city and the rest of the men to the west. Joshua spent the night in the valley.
When the king of Ai saw Joshua's men, he acted quickly. He and all his men went out toward the Jordan Valley to fight the Israelites at the same place as before, not knowing that he was about to be attacked from the rear.
Joshua and his men pretended that they were retreating, and ran away toward the barren country.
All the men in the city had been called together to go after them, and as they pursued Joshua, they kept getting farther away from the city.
Every man in Ai went after the Israelites, and the city was left wide open, with no one to defend it.
References for Joshua 8:17
Then the Lord said to Joshua, "Point your spear at Ai; I am giving it to you." Joshua did as he was told,
and as soon as he lifted his hand, the men who had been hiding got up quickly, ran into the city and captured it. They immediately set the city on fire.
When the men of Ai looked back, they saw the smoke rising to the sky. There was no way for them to escape, because the Israelites who had run toward the barren country now turned around to attack them.
When Joshua and his men saw that the others had taken the city and that it was on fire, they turned around and began killing the men of Ai.
The Israelites in the city now came down to join the battle. So the men of Ai found themselves completely surrounded by Israelites, and they were all killed. No one got away, and no one lived through it
except the king of Ai. He was captured and taken to Joshua.
The Israelites killed every one of the enemy in the barren country where they had chased them. Then they went back to Ai and killed everyone there.
Joshua kept his spear pointed at Ai and did not put it down until every person there had been killed. The whole population of Ai was killed that day - twelve thousand men and women.
The Israelites kept for themselves the livestock and goods captured in the city, as the Lord had told Joshua.
Joshua burned Ai and left it in ruins. It is still like that today.
He hanged the king of Ai from a tree and left his body there until evening. At sundown Joshua gave orders for the body to be removed, and it was thrown down at the entrance to the city gate. They covered it with a huge pile of stones, which is still there today.