2 Samuel 3:30

So Joab and Abishai his brother slew Abner, because he had slain their brother Asahel at Gibeon in the battle.

The killing took place during the long war between the house of Saul and the house of David, in connection with Abner's revolt to David. Joab, together with his brother Abishai, slew Abner. The act was done in revenge because Abner had killed their brother Asahel at Gibeon in the battle. It was done on account of the slaying of Saul's son Ishbosheth.

Abner's death was one of the political events preceding David's rule over all Israel. David neither wanted nor connived in the murders of Abner and Ish-bosheth, but openly repudiated them.