Joshua 8:9

Joshua therefore sent them forth: and they went to lie in ambush, and abode between Beth-el and Ai, on the west side of Ai: but Joshua lodged that night among the people.

The ambush west of Ai between Bethel and Ai was sent out from Gilgal, Israel's first encampment in the promised land on a plain rich in history where the twelve stones were set up for the crossing of the Jordan, the manna ceased, circumcision was renewed, the first Passover after the wanderings was kept, and the Captain of the Lord's host appeared. The sending belongs to Israel's renewed and second advance against Ai after the sentence upon Achan was carried out. The execution of the divine sentence upon Achan had turned away the wrath of God from Israel.

For this renewed advance Joshua marshaled all the men of war as commanded. In the renewed attack divine power accompanied Israel and the city was soon taken, with the armies of Heaven fighting for Israel and putting their enemies to flight. The victory showed that Israel's only hope was obedience to God.