Allaah (The Most High) said:
وَكَذَٲلِكَ جَعَلۡنَا فِى كُلِّ قَرۡيَةٍ أَڪَـٰبِرَ مُجۡرِمِيهَا لِيَمۡڪُرُواْ فِيهَاۖ وَمَا يَمۡڪُرُونَ إِلَّا بِأَنفُسِہِمۡ وَمَا يَشۡعُرُونَ
”And thus We have set up in every town the greatest of its criminals to plot therein. But they plot not except against their ownselves, and they perceive (it) not.” [Soorah Al-An’aam: Ayah 123]
[وَكَذَٲلِكَ جَعَلۡنَا فِى كُلِّ قَرۡيَةٍ أَڪَـٰبِرَ مُجۡرِمِيهَا] ”And thus We have set up in every town great ones of its wicked people;” That is those figureheads whose crimes were great and whose transgressions were severe.
[لِيَمۡڪُرُواْ فِيهَاۖ] ”to plot therein” with deceit; calling to the path of shaytaan; waging war against the Messengers and their followers through speech and action. However, their plots and machinations only backfired on them. That is because they plotted and Allah too was planning, and Allah is the Best of the planners.
Likewise Allaah set up great ones amongst the leaders of guidance and the most virtuous of them, who opposed those criminals; refuted their statements and strove against them in the path of Allaah. They followed the paths leading to the path (of Allaah) and Allaah aided them. Allaah gave them an acute discernment and kept them steadfast. So the days of victory and defeat alternated between them and their enemies, until the affair came to its final end—victory and triumph (for the believers) and the good final end is for the Muttaqoon (i.e. the pious and righteous persons who fear Allah much (abstain from all kinds of sins and evil deeds which He has forbidden) and love Allah much (perform all kinds of good deeds which He has ordained)].
[Source: Tayseer Al-kareem Ar-Rahmaan Fee Tafseer kalaam Al-Mannaan of Imaam Sadi (rahimahullaah)] Slightly paraphrased and abridged]