The Israelites all worshiped other gods but then other people went to war against them. They were desperate and cried out to the one true God and He heard their cry.
Judges 6 ~
6 Again the Israelites did evil in the Lord’s sight. They served the images of Baal and Ashtoreth, and the gods of Aram, Sidon, Moab, Ammon, and Philistia. They abandoned the Lord and no longer served him at all. 7 So the Lord burned with anger against Israel, and he turned them over to the Philistines and the Ammonites, 8 who began to oppress them that year. For eighteen years they oppressed all the Israelites east of the Jordan River in the land of the Amorites (that is, in Gilead).9 The Ammonites also crossed to the west side of the Jordan and attacked Judah, Benjamin, and Ephraim.
The Israelites were in great distress.10 Finally, they cried out to the Lord for help, saying, “We have sinned against you because we have abandoned you as our God and have served the images of Baal.”
11 The Lord replied, “Did I not rescue you from the Egyptians, the Amorites, the Ammonites, the Philistines, 12 the Sidonians, the Amalekites, and the Maonites? When they oppressed you, you cried out to me for help, and I rescued you. 13 Yet you have abandoned me and served other gods. So I will not rescue you anymore. 14 Go and cry out to the gods you have chosen! Let them rescue you in your hour of distress!”
15 But the Israelites pleaded with the Lord and said, “We have sinned. Punish us as you see fit, only rescue us today from our enemies.” 16 Then the Israelites put aside their foreign gods and served the Lord. And he was grieved by their misery.