When Joshua and all Israel saw that the men in ambush had captured the city and that smoke was rising from it, they turned back and struck down the men of Ai.
In context
19As soon as he stretched out his hand, the men in ambush rose quickly from their place and rushed in. They entered the city, captured it, and hurried to set it on fire. 20When the men of Ai looked back, they saw the smoke of the city rising to the sky, and they had no way to flee in any direction, for the people who had been fleeing toward the wilderness turned back against their pursuers. 21When Joshua and all Israel saw that the men in ambush had captured the city and that smoke was rising from it, they turned back and struck down the men of Ai. 22The others came out of the city to meet them, so the men of Ai were caught in the middle, Israelites on both sides. Israel struck them down until no one was left alive or able to escape. 23But they took the king of Ai alive and brought him to Joshua.