When the Philistines heard that David had been anointed king over Israel, they went up in full force to search for him, but David heard about it and went down to the stronghold.1
References for 2 Samuel 5:17
Now the Philistines had come and spread out in the Valley of Rephaim;2
References for 2 Samuel 5:18
so David inquired3 of the LORD, "Shall I go and attack the Philistines? Will you hand them over to me?" The LORD answered him, "Go, for I will surely hand the Philistines over to you."
References for 2 Samuel 5:19
So David went to Baal Perazim, and there he defeated them. He said, "As waters break out, the LORD has broken out against my enemies before me." So that place was called Baal Perazim.4
References for 2 Samuel 5:20
The Philistines abandoned their idols there, and David and his men carried them off.5
References for 2 Samuel 5:21
Once more the Philistines came up and spread out in the Valley of Rephaim;
so David inquired of the LORD, and he answered, "Do not go straight up, but circle around behind them and attack them in front of the balsam trees.
As soon as you hear the sound6 of marching in the tops of the balsam trees, move quickly, because that will mean the LORD has gone out in front7 of you to strike the Philistine army."
References for 2 Samuel 5:24
So David did as the LORD commanded him, and he struck down the Philistines8 all the way from Gibeon9 to Gezer.10
References for 2 Samuel 5:25