2 Samuel 5:17-25 Common English Bible (CEB)
David defeats the Philistines
17 When the Philistines heard that David had been anointed king over Israel, they all marched up to find him, but David heard of it and went down to the fortress. 18 The Philistines arrived and spread out over the Rephaim Valley. 19 David asked the Lord, “Should I attack the Philistines? Will you hand them over to me?”
“Attack them,” the Lord replied, “because I will definitely hand the Philistines over to you.”
20 So David arrived at Baal-perazim and defeated the Philistines there. He said, “The Lord has burst out against my enemies, the way water bursts out!” That is why that place is called Baal-perazim.[a] 21 The Philistines left their divine images behind, and David and his men carried them off.
22 Once again the Philistines came up and spread out across the Rephaim Valley. 23 When David asked the Lord, God replied, “Don’t attack them directly. Circle around behind them and come at them from in front of the balsam trees. 24 As soon as you hear the sound of marching in the tops of the trees, then attack, for God has attacked in front of you to defeat the Philistine army.” 25 David followed God’s orders exactly, and they defeated the Philistine army from Gibeon all the way to Gezer.