5:17 When the Philistines heard that David had been designated king over Israel, they all went up to search for David. When David heard about it, he went down to the fortress. 5:18 Now the Philistines had arrived and spread out in the valley of Rephaim. 5:19 So David asked the Lord, “Should I march up against the Philistines? Will you hand them over to me?” The Lord said to David, “March up, for I will indeed hand the Philistines over to you.”
5:20 So David marched against Baal Perazim and defeated them there. Then he said, “The Lord has burst out against my enemies like water bursts out.” So he called the name of that place Baal Perazim. 5:21 The Philistines abandoned their idols there, and David and his men picked them up.
5:22 The Philistines again came up and spread out in the valley of Rephaim. 5:23 So David asked the Lord what he should do. This time the Lord said to him, “Don’t march straight up. Instead, circle around behind them and come against them opposite the trees. 5:24 When you hear the sound of marching in the tops of the trees, act decisively. For at that moment the Lord is going before you to strike down the army of the Philistines.” 5:25 David did just as the Lord commanded him, and he struck down the Philistines from Gibeon all the way to Gezer.
8:1 Later David defeated the Philistines and subdued them. David took Metheg Ammah from the Philistines.