Then the Lord said to Joshua, "Don't be afraid; don't give up. Lead all your fighting men to Ai. I will help you defeat the king of Ai. I am giving you his people, his city, and his land.
You will do to Ai and its king the same thing you did to Jericho and its king. Only this time you can take all the wealth and animals and keep it for yourselves. You will share the wealth with your people. Now, tell some of your soldiers to hide behind the city."
Joshua gave them this command: "Listen carefully to what I tell you. You must hide in the area behind the city. Wait for the time to attack. Don't go far from the city. Continue to watch and be ready.
I will lead the men with me; we will march toward the city. The men in the city will come out to fight against us. We will turn and run away from them, as we did before.
Then Joshua sent them to their hiding place and waited. They went to a place west of Ai, between Bethel and Ai. But Joshua stayed the night with his people.
All of the soldiers who were with Joshua marched to Ai. They stopped in front of the city. The army made its camp north of the city. There was a valley between the army and Ai.
So Joshua had prepared his men for the fight. The main camp was north of the city. The other men were hiding to the west. That night Joshua went down into the valley.
Later, the king of Ai saw the army of Israel. The king and his people hurried out to fight the army of Israel. The king of Ai went out the east side of the city toward the Jordan Valley, so he did not see the soldiers hiding behind the city.
When the Israelites who were hiding saw this, they quickly came out from their hiding place and hurried toward the city. They entered the city and took control of it. Then the soldiers started fires to burn the city.
The men from Ai looked back and saw their city burning. They saw the smoke rising into the sky. So they lost their strength and courage. They stopped chasing the men of Israel. The Israelites stopped running away. They turned and went to fight the men from Ai. There was no safe place for the men from Ai to run to.
When Joshua and his men saw that his army had taken control of the city and that smoke was rising from it, they stopped running away and turned to fight the men of Ai.
Then the men who were hiding came out of the city to help with the fight. The army of Israel was on both sides of the men of Ai—the men of Ai were trapped. Israel defeated them. They fought until none of the men from Ai were left alive— none of the enemy escaped.
During the fighting, the army of Israel chased the men from Ai into the fields and into the desert. So the army of Israel finished killing all the men from Ai in the fields and in the desert. Then the Israelites went back to Ai and killed all the people who were still alive in the city.
The Israelites kept the animals and other things from the city for themselves. This is what the Lord said they could do when he gave Joshua the commands.
Joshua hanged the king of Ai on a tree and left him hanging there until evening. At sunset, Joshua told his men to take the king's body down from the tree. They threw his body down at the city gate. Then they covered the body with many rocks. That pile of rocks is still there today.
The Lord's servant Moses told the Israelites how to build altars. So Joshua built the altar the way it was explained in the Book of the Law of Moses. The altar was made from stones that were not cut. No tool had ever been used on those stones. They offered burnt offerings to the Lord on that altar. They also gave fellowship offerings.
The elders, officers, judges, and all the Israelites were standing around the Holy Box. They were standing in front of the priests, the Levites who carried the Holy Box of the Lord's Agreement. The Israelites and the other people with them were all standing there. Half of the people stood in front of Mount Ebal and the other half of the people stood in front of Mount Gerizim. The Lord's servant Moses had told the people to do this. He told them to do this to be blessed.
All the Israelites were gathered together there. All the women and children and all the foreigners who lived with the Israelites were there. And Joshua read every command that Moses had given.