2 Samuel5:17

When the Philistines heard that David had been anointed king over Israel, all of them came up to seek him in an invading attack. On hearing of their advance, David went down to the hold, which was the stronghold of Zion. There he waited for divine direction rather than moving at once against the invaders. The victories that followed came as he sought the Lord's instructions and followed them.

This conflict belongs among the events that established David securely on the throne. It came before he turned to bring the ark to Jerusalem.