The Lord tells Joshua not to fear or be dismayed: he is to take all the fighting men and go up against Ai, for the Lord has given him the king, the people, the city and the land. Unlike Jericho, this time the people may take the plunder and the livestock for themselves. Joshua chooses thirty thousand mighty men and sends them by night to lie in ambush behind the city, while he and the rest advance from the front.
When the men of Ai come out to fight, Joshua and his men pretend to flee as they did the first time. All the men of Ai pursue them and leave the city open. The Lord tells Joshua to stretch out his javelin toward Ai, and the ambush rises, enters the city and sets it on fire. The men of Ai look back and see the smoke; the Israelites turn and strike them from both sides until no survivor or fugitive remains. They capture the king of Ai alive and bring him to Joshua. Twelve thousand fall, men and women. Joshua does not draw back his hand until all the inhabitants are destroyed. Israel takes the livestock and the plunder, and the city is left a heap of ruins forever. The king is hanged on a tree until evening, and at sunset they take him down and raise a heap of stones over his body.
Then Joshua builds an altar to the Lord on Mount Ebal, of uncut stones, as Moses had commanded, and they offer burnt offerings and peace offerings. Joshua writes on stones a copy of the law of Moses in front of the sons of Israel. All the people, with the elders and judges, stand on both sides of the ark, half in front of Mount Gerizim and half in front of Mount Ebal. Joshua reads all the words of the law, the blessings and the curses, before the whole assembly, including the women, the children and the foreigners.