David kept on weeping and mourning the death of his rebellious son Absalom so that he was failing to thank his soldiers for having fought for him. Thus Joab denounced this imbalance of emotions and told David that is he didn't show gratitude to the men he would soon lose their backing. David heeded Joab and got up and took his seat in the gateway demonstrating his willingness to be reinstated as king with the support of the army.
Initially there was disagreement as to who should now be king after the Absalom fiasco, but David made a clever diplomatic and political move appointing Amasa, who had been the commander of Absalom's army, as commander of his army replacing Joab, and this unified support for David so that the men sent word to David to return to Jerusalem as king.
When David crossed the River Jordan Shimei met him together with a thousand Benjamites and pleaded for forgiveness for having cursed David and thrown stones at him. Abishai said that Shimei should be put to death, but David wouldn't hear of it. David forgave Shimei and promised him freedom to live. Then Mephibosheth came to David and said that his servant Ziba deceived and betrayed him on the occasion of Ziba's earlier encounter with David, and that he had only not gone with David when he fled because he was lame. As a consequence David divided Mephibosheth's land half and half between him and Ziba though the text is not clear how this ended up. Finally David spoke to Barzillai and invited him to go with him to Jerusalem but he declined alleging old age, and he sent his servant in his place.
Tensions were always near the surface between the men of Israel and the men of Judah, with the former group accusing the latter group of leaving them out of the reinstatement of David as king. A fierce argument ensued.