17 When the Philistines heard that David had been anointed king over Israel, all the Philistines went up in search of David; but David heard about it and went down to the stronghold. 18 Now the Philistines had come and spread out in the valley of Rephaim. 19 David inquired of the Lord, "Shall I go up against the Philistines? Will you give them into my hand?" The Lord said to David, "Go up; for I will certainly give the Philistines into your hand." 20 So David came to Baal-perazim, and David defeated them there. He said, "The Lord has burst forth against my enemies before me, like a bursting flood." Therefore that place is called Baal-perazim. 21 The Philistines abandoned their idols there, and David and his men carried them away. 22 Once again the Philistines came up, and were spread out in the valley of Rephaim.
Matthew Henry's Commentary on 2 Samuel 5:17-22
Commentary on 2 Samuel 5:17-25
(Read 2 Samuel 5:17-25)
The Philistines considered not that David had the presence of God with him, which Saul had forfeited and lost. The kingdom of the Messiah, as soon as it was set up in the world, was thus attacked by the powers of darkness. The heathen raged, and the kings of the earth set themselves to oppose it; but all in vain, Acts 2:2.