21 Then all the men of his city must stone him to death. In this way you will purge wickedness from among you, and all Israel will hear about it and be afraid. 22 If a person commits a sin punishable by death and is executed, and you hang the corpse on a tree, 23 his body must not remain all night on the tree; instead you must make certain you bury him that same day, for the one who is left exposed on a tree is cursed by God. You must not defile your land that the Lord your God is giving you as an inheritance.
27 But Israel did plunder the cattle and the goods of the city, in keeping with the Lord’s orders to Joshua. 28 Joshua burned Ai and made it a permanently uninhabited mound (it remains that way to this very day). 29 He hung the king of Ai on a tree, leaving him exposed until evening. At sunset Joshua ordered that his corpse be taken down from the tree. They threw it down at the entrance of the city gate and erected over it a large pile of stones (it remains to this very day). 30 Then Joshua built an altar for the Lord God of Israel on Mount Ebal, 31 just as Moses the Lord’s servant had commanded the Israelites. As described in the law scroll of Moses, it was made with uncut stones untouched by an iron tool. On it they offered burnt sacrifices to the Lord and sacrificed tokens of peace.
Notes and References
"... In my opinion, the description of impalement in Joshua 8:29 was not initially designed to illustrate Deuteronomic law, but rather takes its inspiration from the prevalent Neo-Assyrian practice directed against foreign enemies in wartime. The reliefs of the conquest of Lachish illustrate how Sennacherib carried out this practice in Judah during his third campaign. In my opinion, the early conquest account did not object to the idea that the Israelites should treat the kings of Canaan in the same fashion that Assyrians had treated Judean captives during the campaigns of the seventh century. I think that a later scribe, in the late sixth century or later, assumed that the rationale that was added to the law in Deuteronomy 21:22–23 should also apply to the period of the conquest in order to preserve the land of Israel’s inheritance from pollution. To this end, he added the details about removing the body of the king of Ai at sunset and interning his corpse in the cairn. In this case, a late Deuteronomistic revision of the Ai narrative employed the law in Deuteronomy 21:22–23 in an exegetical fashion ..."
Edenburg, Cynthia "Paradigm, Illustrative Narrative, or Midrash: The Case of Josh 7-8 and Deuteronomic/istic Law" in Berner, Christoph (ed.) The Reception of Biblical War Legislation in Narrative Contexts: Proceedings of the EABS Research Group "Law and Narrative" (pp. 163-178) De Gruyter, 2015