The absolute defeat of the city of Ai unfolded in two distinct phases, beginning with a clash in the open territory and ending within the city walls. The pursuit and initial defeat of the enemy fighters took place in the wilderness. Because open land can refer to either cultivated farmland or grazing pastures, the location is specifically identified as the wilderness to pinpoint exactly where the chase occurred [רד״ק].
Once the warriors were defeated outside, the Israelites turned their attention back to the city itself. There, they struck down the remaining population, including the women, children, and elderly, who had not yet perished in the fires [מצודת דוד, אברבנאל].
The complete destruction of the city served several crucial purposes. First, it established a powerful deterrence, ensuring that other regional kings would hear of the event and fear going to war against the Israelites. Second, the ruins stood as a lasting monument to God's careful providence. It also served as a permanent reminder of the Israelites' initial failure and sin during their first attempt to conquer the city, as well as their subsequent repentance.
The aftermath of this battle differed significantly from the earlier conquest of Jericho. Joshua did not place a curse on anyone who might rebuild Ai, simply because the location was not suited to be rebuilt to its former state anyway. Furthermore, unlike at Jericho, the Israelites were permitted to take the spoils of the city. This permission was granted to honor the bravery of the fighting men and to remove the temptation of stealing forbidden items, thereby preventing a repeat of the tragic embezzlement that had occurred previously [אברבנאל].