The next city for the Israelites to capture was Ai. Joshua sent a group of men from Gilgal to spy out the city about ten miles from Jericho. They returned to the camp with the report that there were only about ten thousand inhabitants there and it would be easy to capture. About three thousand men were sent to capture the city, BUT they were defeated in their attempt.
Joshua was devastated and stated to God that it would have been better if they had stayed in the wilderness than to be destroyed by the Amorites. God informed him that they had taken some the accursed things and for him to find and burn the items and those who took them. It was determined that Achan was the guilty person and he and all his family were stoned. They and his possessions were burned.
God came again to Joshua and gave instructions for taking Ai. He placed about thirty thousand men north of town and about five thousand on the west side. Joshua and the remaining men approached the city as decoys and drew the king and his army out into pursuit of them. As the main Israelite army closed in on the city, God commanded Joshua to stretch out his sword. That allowed for the total defeat of Ai. The city was looted and burned with the Israelites being allowed to keep the spoils of battle for themselves on that occasion.
After the defeat of Ai, Joshua built an altar in Mount Ebal and offered burnt and peace offerings to the Lord. He then wrote the Law of Moses on the stones and read the law to the people as a reminder of the covenant between them and God.