Although they had lost three dozen men at Ai earlier, there was nothing to fear now since God was with them. God instructed all the men of war to fight, and not just a few thousand as had been done on the former occasion (cf. 7:4). Joshua instructed the people accordingly and employed the very effective plan of attack that God commanded. 30,000 mighty men of valor were sent away by night to position themselves behind the city of Ai secretly. They would lie in ambush, waiting for the proper moment to strike. Commander Joshua would lead the rest of the men toward the front of the city as if they were going to attack. Then, when the men of Ai came out to engage them in battle, the main group of Israelites would turn and run, as if they were scared and defeated. No doubt this would embolden the warriors of Ai who had seen cowardly behavior out of the Israelites on the prior occasion. The plan was executed perfectly. As the men of Ai pursued the Israelites they left their own city exposed and open to attack! They would soon learn a hard lesson--things aren't always as they appear!
"Then the LORD said to Joshua, 'Stretch out the spear that is in your hand toward Ai, for I will give it into your hand.' And Joshua stretched out the spear that was in his hand toward the city. So those in ambush arose quickly out of their place; they ran as soon as he had stretched out his hand, and they entered the city and took it, and hurried to set the city on fire. And when the men of Ai looked behind them, they saw, and behold, the smoke of the city ascended to heaven. So they had not power to flee this way or that way, and the people who had fled to the wilderness turned back on the pursuers. Now when Joshua and all Israel saw that the ambush had taken the city and that the smoke of the city ascended, they turned back and struck down the men of Ai. Then the others came out of the city against them; so they were caught in the midst of Israel, some on this side and some on that side. And they struck them down, so that they let none of them remain or escape. But the king of Ai they took alive, and brought him to Joshua" (8:18-23).
As commanded, all the inhabitants of Ai were annihilated--12,000 in all. Spoil was taken by the Israelites since God had authorized it on this occasion (if only Achan had waited!). The king of Ai was hanged and thus humiliated publicly (cf. Deut. 21:22,23). The city was turned into a burned heap of desolation!
Afterward, Joshua constructed an altar and made a copy of the law of Moses. This too was prescribed by God on an earlier occasion (cf. Deut. 27ff). The people assembled for the reading of the law in what we might call a natural amphitheater. Half gathered near Mount Gerizim and the other half near Mount Ebal, with the ark of the covenant--attended by the priests--in the middle. The priests blessed the people and then Joshua proceeded to "read all the words of the law, the blessings and the cursings, according to all that is written in the Book of the Law. There was not a word of all that Moses had commanded which Joshua did not read before all the assembly of Israel, with the women, the little ones, and the strangers who were living among them" (Josh. 8:34,35). The people needed to know the law in order to know what God expected of them. If they obeyed Him, they would be blessed, but if they disobeyed they would be cursed--just like the Canaanite people they were in the process of destroying from the land.