2 Samuel 10:1-9

1 Later the king of Ammon died, and his son Hanun became king in his place.
2 David thought, "I will show kindness to Hanun as his father Nahash showed me kindness." So David sent his servants to comfort Hanun after his father's [death]. But when David's servants entered Ammonite territory,
3 the Ammonite princes asked their master Hanun, "Do you think David is honoring your father because he sent men to comfort you? Hasn't David sent his men to explore the city, spy on it, and destroy it?"
4 So Hanun took David's men, shaved off half of each man's beard, cut off their clothes from the waist down, and sent them away.
5 After David was told [what had happened], 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]."
6 The Ammonites realized that they had made themselves offensive to David. So they hired the Arameans from Beth Rehob and Zobah (20,000 foot soldiers), [the army of] the king of Maacah (1,000 men), and the men of Tob (12,000 men).
7 After David heard about this, he sent Joab and all the elite troops.
8 The Ammonites formed a battle line at the entrance of the [city] gate, while the Arameans from Zobah and Rehob and the men from Tob and Maacah remained by themselves in the open country.
9 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.