Commentaries
8:23-29 God, the righteous Judge, had sentenced the Canaanites for their wickedness; the Israelites only executed his doom. None of their conduct can be drawn into an example for others. Especial reason no doubt there was for this severity to the king of Ai; it is likely he had been notoriously wicked and vile, and a blasphemer of the God of Israel.
Jos 8:29. The King Hanged.
29. The king of Ai he hanged on a tree until eventide—that is, gibbeted. In ancient, and particularly Oriental wars, the chiefs, when taken prisoners, were usually executed. The Israelites were obliged, by the divine law, to put them to death. The execution of the king of Ai would tend to facilitate the conquest of the land, by striking terror into the other chiefs, and making it appear a judicial process, in which they were inflicting the vengeance of God upon His enemies.
take his carcass down … and raise thereon a great heap of stones—It was taken down at sunset, according to the divine command (De 21:23), and cast into a pit dug "at the entering of the gate," because that was the most public place. An immense cairn was raised over his grave—an ancient usage, still existing in the East, whereby is marked the sepulchre of persons whose memory is infamous.