Yehoshua sent spies into Ai to see how the people would react if the Israelites conquered it. When Yehoshua attacked Ai with only 3000 soldiers, thinking it was weak, the Israelites were defeated. Hashem told Yehoshua that an Israelite named Achan had stolen precious items from Jericho in disobedience, which caused their defeat. Yehoshua devised a plan where some Israelites attacked Ai directly while 30,000 laid in ambush, tricking the king into leaving the city undefended so they could capture and burn it, achieving victory.