17 When the Philistines got word that David had been made king over all Israel, they came on the hunt for him. David heard of it and went down to the stronghold. When the Philistines arrived, they deployed their forces in Raphaim Valley. 19 Then David prayed to God: "Shall I go up and fight the Philistines? Will you help me beat them?" 20 "Go up," God replied. "Count on me. I'll help you beat them." David then went straight to Baal Perazim, and smashed them to pieces. Afterward David said, "God exploded on my enemies like a gush of water." That's why David named the place Baal Perazim (The-Master-Who-Explodes). The retreating Philistines dumped their idols, and David and his soldiers took them away.
22 Later there was a repeat performance. The Philistines came up again and deployed their troops in the Rephaim Valley. David again prayed to God. 23 This time God said, "Don't attack them head-on. Instead, circle around behind them and ambush them from the grove of sacred trees. When you hear the sound of shuffling in the trees, get ready to move out. It's a signal that God is going ahead of you to smash the Philistine camp." 25 David did exactly what God told him. He routed the Philistines all the way from Gibeon to Gezer.