Joab killed Abner at Hebron, presenting it as payback for Asahel’s death. David publicly declared he and his kingdom were guiltless of Abner’s blood and led mourning for him. See 2 Samuel 3:27–32.
In 2 Samuel 3:22–30, Joab returns from a raid to learn that David has dismissed Abner safely. Joab challenges David’s judgment, accusing Abner of spying. Without David’s knowledge, Joab recalls Abner to Hebron and kills him at the city gate, claiming revenge for Asahel. This scene continues the account of shifting power after Saul’s death, where rival leadership structures compete and alliances change. Just before this, Abner had negotiated with David and departed “in peace,” signaling a move toward unifying Israel under David.
The passage presents a sharp contrast between David’s public stance and Joab’s private action. Abner leaves Hebron “in peace,” meaning David has dismissed him safely, and the narrator emphasizes that David did not know about Joab’s recall (verses 22–23, 26).
A careful answer keeps the immediate passage, the book's argument, and the whole-Bible storyline together, so the question is answered in context instead of as a detached idea.
Start with 2 Samuel 3:27-32, then read the surrounding section so the answer stays connected to the passage's flow.
27When Abner was returned to Hebron, Joab took him aside into the midst of the gate to speak with him quietly, and struck him there in the body, so that he died, for the blood of Asahel his brother.
28Afterward, when David heard it, he said, I and my kingdom are guiltless before Yahweh forever of the blood of Abner the son of Ner:
29let it fall on the head of Joab, and on all his father`s house; and let there not fail from the house of Joab one who has an issue, or who is a leper, or who leans on a staff, or who falls by the sword, or who lacks bread.
30So Joab and Abishai his brother killed Abner, because he had killed their brother Asahel at Gibeon in the battle.
31David said to Joab, and to all the people who were with him, Tear your clothes, and gird you with sackcloth, and mourn before Abner. King David followed the bier.
32They buried Abner in Hebron: and the king lifted up his voice, and wept at the grave of Abner; and all the people wept.