After Jericho, the narrator warns us before Joshua knows: the children of Israel committed a trespass in the devoted things, for Achan took some of them, and Yahweh's anger burned. Joshua sent about three thousand men to Ai on the spies' advice. Israel fled, about thirty-six men were struck down, and the hearts of the people melted.
Joshua tore his clothes and lay before the ark until evening, asking what Yahweh would do for His great name. God told him to get up, because Israel has sinned. They have taken devoted things, stolen, and deceived. Israel could not stand before its enemies until the devoted thing was removed. The defeat was not about weak soldiers but about broken covenant.
Tribe by tribe, family by family, Achan was taken. Joshua said, My son, please give glory to Yahweh, the God of Israel, and make confession to him. Achan answered, I have truly sinned against Yahweh. His sin followed a clear path: he saw, coveted, took, and hid. Achan was put to death by stoning as God's judgment, a heap of stones marked the valley of Achor, and Yahweh turned from His anger. In the New Testament, If we confess our sins, he is faithful and righteous to forgive us the sins (1 John 1:9).