The battle described in these verses appears to be the one retold in 23:13-17. It could have taken place between David's anointing as king over all Israel (v. 17; cf. v. 3) and his capture of Jerusalem (vv. 6-9)71or perhaps shortly after he had conquered Jerusalem.72The stronghold (v. 17) in the first case may have been the cave of Adullam (23:13) northwest of Hebron (v. 3) about 11 miles.73If this battle took place after the capture of Jerusalem, the stronghold probably refers to Zion (v. 7). The valley of Rephaim (v. 18; 23:13) was just southwest of Jerusalem where the Philistines massed for battle. Bethlehem, the site of the Philistine garrison (23:14), stood beside this valley. The Philistines probably wanted to defeat David at once before he could take the offensive and begin to establish himself and expand his kingdom.
God granted David's request for his sovereign's strategy, and victory followed for Israel. Baal-perazim (lit. lord of breakthroughs) memorialized the Lord's victory (v. 20). Notice how David acknowledged Yahweh's ultimate authority over Israel in contrast to how Saul did not. The Philistines' idols that they carried into battle to secure victory (blessing) proved useless, so the Philistines abandoned them (v. 21). The Israelites then burned them (1 Chron. 14:12).