Later King Nahash of Ammon died, and his son became king in his place.
David thought, "I will show kindness to Hanun because his father Nahash showed me kindness." So David sent messengers to comfort Hanun after his father's [death]. But when David's servants entered Ammonite territory to comfort Hanun,
the Ammonite princes asked Hanun, "Do you think David is honoring your father because he sent men to comfort you? Haven't his servants come to explore, destroy, and spy on the country?"
So Hanun took David's men, shaved them, cut off their clothes from the waist down, and sent them away.
After people told David [what had happened] to the men, he sent [someone] to meet them because they were deeply humiliated. The king said to them, "Stay in Jericho until your beards have grown back, and then return [to Jerusalem]."
The Ammonites realized that they had made themselves offensive to David. So Hanun and the Ammonites sent 75,000 pounds of silver to hire chariots and horses from the Arameans in Upper Mesopotamia, Maacah, and Zobah.
They hired 32,000 chariots and the king of Maacah with his army. They camped near Medeba. The Ammonites gathered for the battle from their cities.
After David heard about this, he sent Joab and all the elite troops.
The Ammonites formed a battle line at the entrance of the city, while the Arameans from Zobah and Rehob and the kings who had come remained by themselves in the open country.
When Joab saw he was under attack in front and behind, he took the select troops of Israel and organized them for combat against the Arameans.
He put his brother Abishai in charge of the rest of the troops. They organized for combat against the Ammonites.
Joab said, "If the Arameans are too strong for my [troops], be ready to help me. And if the Ammonites are too strong for your [troops], I'll help you.
Be strong! Let's prove ourselves strong for our people and for the cities of our God, and the LORD will do what he considers right."
Then Joab and his troops advanced to fight the Arameans, and the Arameans fled.
When the Ammonites saw that the Arameans had fled, they, too, fled from Joab's brother Abishai and went into the city. So Joab returned to Jerusalem.
Realizing that Israel had defeated them, the kings sent [messengers] to get [other] Arameans from beyond the Euphrates River. Shophach, the commander of Hadadezer's army, led them.
When David was told [about this], he assembled Israel's army, crossed the Jordan, and confronted them. David formed a battle line against the Arameans, and they fought him.
The Arameans fled from Israel, and David killed 7,000 chariot drivers and 40,000 foot soldiers. David also killed Shophach.
When all the kings who were subject to Hadadezer saw that Israel had defeated them, they made peace with David and became his subjects. And the Arameans were no longer willing to help the Ammonites.