Habakkuk to  1 Chronicles

The head of the wicked severed.

Saul's Beheading

13You went forth to save your people and to save your anointed; you cut off the head out of the house of the wicked, you have laid him bare from his foundations, even to the neck forever. (Habakkuk 3:13 BRB)
8It came to pass on the next day, when the Philistines came to strip the killed, they found Saul and his 3 sons killed on the mount of Gilboa. 9They cut off their heads, stripped them of their armour, and sent them to the land of the Philistines, throughout the towns and cities and provinces to carry the good news to their idols and to their people; 10and they put their garments and their armour in the house of their idols, and hung their bodies by the wall in the house of Dagon. 1 Chronicles 10:8-10 (1 Chronicles 10:8-10 BRB)

Habakkuk ends with a prayer. In the prayer Yahvah is described as delivering his anointed by cutting off the head of the wicked. The first story in First Chronicles is the death of King Saul. Saul fell on his own sword to prevent being mistreated by the Philistines who were closing in around him, but when the Philistines found him they cut off his head anyhow. This is the beheading in Habakkuk's prayer.

So if Saul is the "wicked" whose head was cut off to deliver Yahvah's anointed, then who is Yahvah's anointed? David, of course. David had been anointed by the prophet Samuel to reign over Israel after Saul. Saul was jealous of David's anointing, which gave him military victories and rapport with the nation, and he sought to kill David in an attempt to keep the throne in the family. David was on the run from Saul for a long time to preserve his life, despite trying to reconcile a number of times and passing up more than one opportunity to take Saul's life.

The clue Habakkuk is adding to this story is that Saul's death was Yahvah's doing. The mechanism Yahvah used was the Philistine army, but he could have caused them not to war against Israel or delivered Saul's life. Habakkuk is saying that this was a deliverance for David. Since David had entrusted his life to Yahvah, and would not himself take the life of Yahvah's anointed, which at that time was Saul, Yahvah took Saul's life when it was time. The irony is that Saul, despite knowing David was anointed to be king after him, attempted time and again to end David's life. The contrast is what makes Saul wicked and David worthy.