17Now when the Philistines heard that they had anointed David king over Israel, all the Philistines went up to search for David. And David heard of it and went down to the stronghold. 18The Philistines also went and deployed themselves in the Valley of Rephaim. 19So David inquired of the Lord, saying, “Shall I go up against the Philistines? Will You deliver them into my hand?”
And the Lord said to David, “Go up, for I will doubtless deliver the Philistines into your hand.”
20So David went to Baal Perazim, and David defeated them there; and he said, “The Lord has broken through my enemies before me, like a breakthrough of water.” Therefore he called the name of that place [d]Baal Perazim. 21And they left their [e]images there, and David and his men carried them away.
22Then the Philistines went up once again and deployed themselves in the Valley of Rephaim. 23Therefore David inquired of the Lord, and He said, “You shall not go up; circle around behind them, and come upon them in front of the mulberry trees. 24And it shall be, when you hear the sound of marching in the tops of the mulberry trees, then you shall advance quickly. For then the Lord will go out before you to strike the camp of the Philistines.” 25And David did so, as the Lord commanded him; and he drove back the Philistines from Geba[f] as far as Gezer.