After a period of eight years serving the Mesopotamians, God chose a deliverer for the children of Israel. That first judge to lead Israel was Othniel. He was a nephew of Caleb. They had a period of peace/rest for forty years and then Othniel died.
With the death of Othniel came another period of evil among the Israelites. They were defeated by Eglon, the king of Moab and served him for eighteen years. Ehud became their judge after they had cried out to the Lord for deliverance. King Eglon was assassinated by Ehud. He, with God’s help led the children of Israel to victory over the Moabites and they lived another eighty years in rest from their oppressors.
A trend developed with Israel obediently following God and their judge during that judge’s lifetime, but then returning to their evil ways after the judge had died. Shamgar was the third judge recorded as leading the Israelites to deliverance.