When the king of Ai saw the Israelites, he hurried out early in the morning with the men of the city to engage them in battle at an appointed place overlooking the Arabah. But he did not know that an ambush had been set up against him behind the city.
For it was of the LORD to harden their hearts to engage Israel in battle, so that they would be set apart for destruction and would receive no mercy, being annihilated as the LORD had commanded Moses.
When this was reported to David, he gathered all Israel, crossed the Jordan, advanced toward the Arameans, and arrayed for battle against them. When David lined up to engage them in battle, they fought against him.