David's allies, the Ammonites, get a new king named Hanun, after his father dies. David sends envoys to console Hanun about his dad's death, but the Ammonite princes become convinced that they're actually spies bent on overthrowing their city. So yeah, this is a great plan.
The princes convince Hanun to take action. He captures the envoys, cuts off the pelvis-area of their garments, and shaves off their beards halfway, before sending them back to David, totally humiliated.
When David sees how his envoys have been treated, he tells them to recoup in Jericho in order to re-grow their beards.
The Ammonites, seeing how they've managed to tick off David, get ready for a fight—they get tens of thousands of Arameans (and some other people) to march against the Israelites. They mass at the gates of Jerusalem and in the country beyond, surrounding the city in front and behind.
Joab—the head general of the army, now—decides to take some crack troops under his command, while putting the others under the command of his brother, Abishai.
Joab's special forces successfully beat back the Ammonites, causing the Arameans and everyone else to flee, as well.
Aramean Armies Redux
The Arameans and their king (still Hadadezer), probably ashamed at all this, gather together even more Arameans.
They all get together at a place called Helam, under the leader of a commander named Shobach.
David personally leads out an army to defeat them, killing forty thousand of their men, destroying seven hundred chariot teams, and also killing Shobach.
In the end, the Arameans are forced to make peace with Israel and pay tribute to the Israelites.