For when Joshua and all Israel saw that the ambush had taken the city and that smoke was going up from it, they turned around and attacked the men of Ai.
Joab saw that there were battle lines in front of him and behind him; so he selected some of the best troops in Israel and deployed them against the Arameans.
Now Adoni-Zedek king of Jerusalem heard that Joshua had taken Ai and totally destroyed it, doing to Ai and its king as he had done to Jericho and its king, and that the people of Gibeon had made a treaty of peace with Israel and had become their allies.
The men of Ai looked back and saw the smoke of the city rising up into the sky, but they had no chance to escape in any direction; the Israelites who had been fleeing toward the wilderness had turned back against their pursuers.
Those in the ambush also came out of the city against them, so that they were caught in the middle, with Israelites on both sides. Israel cut them down, leaving them neither survivors nor fugitives.