17 When the Philistines heard that they had anointed David king over Israel, all the Philistines went up to seek David; and David heard of it, and went down to the stronghold. 18 Now the Philistines had come and spread themselves in the valley of Rephaim. 19 David inquired of Yahweh, saying, “Shall I go up against the Philistines? Will you deliver them into my hand?”
Yahweh said to David, “Go up; for I will certainly deliver the Philistines into your hand.” 20 David came to Baal Perazim, and David struck them there; and he said, “Yahweh has broken my enemies before me, like the breach of waters.” Therefore he called the name of that place Baal Perazim. 21 They left their images there; and David and his men took them away. 22 The Philistines came up yet again, and spread themselves in the valley of Rephaim. 23 When David inquired of Yahweh, he said, “You shall not go up. Circle around behind them, and attack them over against the mulberry trees. 24 It shall be, when you hear the sound of marching in the tops of the mulberry trees, that then you shall stir yourself up; for then Yahweh has gone out before you to strike the army of the Philistines.” 25 David did so, as Yahweh commanded him, and struck the Philistines from Geba until you come to Gezer.
Matthew Henry's Commentary on 2 Samuel 5:17-25
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.