The capture of an enemy leader marks a significant stage in a military campaign. During the battle, the Israelite fighters successfully took the king of Ai captive while he was still alive.
The exact location of his capture is not specified. He may have stayed behind in the city and been taken during its fall, or he might have gone out to the battlefield to fight alongside his men [ביאור שטיינזלץ]. Regardless of where the capture took place, once the fighters secured the king, they brought him directly to Joshua.