Judges 2:18 - And when the LORD raised them up judges, then the LORD was with the judge, and delivered them out of the hand of their enemies all the days of the judge: for it repented the LORD because of their groanings by reason of them that oppressed them and vexed them.

List of the Judges of Israel and Foreign Oppressors
The OppressorYears of OppressionJudge - DelivererYears of Peace
Mesopotamia8 YearsOthniel40 Years
The Moabites
The Ammonites
The Amalekites
18 YearsEhud80 Years
The Canaanites20 YearsDeborah
40 Years
The Midianites7 YearsGideon40 Years
3 Years
23 Years
22 Years
The Ammonites18 YearsJephthah6 Years
7 Years
10 Years
8 Years
The Philistines40 YearsSamson20 Years
The PhilistinesEli40 Years
The PhilistinesSamuel20 Years
Total111 Years339 Years

The Judges were not necessarily actual judges or elders or rulers in accordance with the traditionally accepted title in ancient Israel. They were actually more like local deliverers who were raised up by God to bring relief to the oppression that was brought about by their enemies. The oppression came because of their lack of faith, although there were some who were faithful, as in the case of Boaz (Ruth 2-4).

Judges 2:17 - And yet they would not hearken unto their judges, but they went a whoring after other gods, and bowed themselves unto them: they turned quickly out of the way which their fathers walked in, obeying the commandments of the LORD; [but] they did not so.