17 When the Philistines had heard that David was anointed king over Israel, they marched out in force to come after him. When David heard this, he went down to the refuge.
18 Meanwhile the Philistines had come and deployed themselves in the valley of Rephaim.
19 David inquired of the Lord, “Shall I attack the Philistines, and will you deliver them into my power?” The Lord answered David: Attack, for I will surely deliver the Philistines into your power.
20 So David went to Baal-perazim, and he defeated them there. He said, “The Lord has broken through my enemies before me just as water breaks through a dam.” Therefore that place was called Baal-perazim.
21 The Philistines abandoned their gods there, and David and his men carried them away.
22 Once again the Philistines came up and deployed themselves in the valley of Rephaim,
23 and again David inquired of the Lord, who replied: Do not attack the front—circle behind them and come against them near the balsam trees.