Joshua 8:4

And he commanded them, saying, Behold, ye shall lie in wait against the city, even behind the city: go not very far from the city, but be ye all ready:

This command was given in Israel's campaign against Ai and belongs to the account of the city's conquest. That campaign was undertaken from Gilgal, Israel's first encampment in the promised land. The overthrow of Ai was one of the victories Israel marched out from Gilgal to accomplish.

It was a renewed advance against Ai that followed Achan's punishment by execution of the divine sentence upon him. That execution turned God's wrath away from Israel. God then commanded Joshua to marshal all the men of war and advance against Ai again. Israel then took the city through God's power, putting its enemies to flight with the armies of heaven fighting for Israel.