Read this passage and open each verse for the full verse feed and commentary tools.
17When the Philistines heard that David had been anointed king over Israel, all the Philistines went up in search of David; but David heard of it and went down to the stronghold. 18Now the Philistines had come and spread out in the valley of Reph'aim. 19And David inquired of the LORD, "Shall I go up against the Philistines? Wilt thou give them into my hand?" And the LORD said to David, "Go up; for I will certainly give the Philistines into your hand." 20And David came to Ba'al-pera'zim, and David defeated them there; and he said, "The LORD has broken through my enemies before me, like a bursting flood." Therefore the name of that place is called Ba'al-pera'zim. 21And the Philistines left their idols there, and David and his men carried them away.
22And the Philistines came up yet again, and spread out in the valley of Reph'aim. 23And when David inquired of the LORD, he said, "You shall not go up; go around to their rear, and come upon them opposite the balsam trees. 24And when you hear the sound of marching in the tops of the balsam trees, then bestir yourself; for then the LORD has gone out before you to smite the army of the Philistines." 25And David did as the LORD commanded him, and smote the Philistines from Geba to Gezer.
2 Samuel 5:17-25 (RSV)