Joshua 8:21

And when Joshua and all Israel saw that the ambush had taken the city, and that the smoke of the city ascended, then they turned again, and slew the men of Ai.

The verse marks the moment when Joshua and all Israel saw that the ambush had taken the city and that its smoke was ascending, and then they turned back and slew the men of Ai. That successful capture of the city came after the sentence upon Achan had been carried out.

The conquest of Ai belongs among the events connected with Israel's first encampment in the promised land. In this battle Israel's enemies were put to flight because the armies of heaven fought for Israel.