Al-An'am - 6:129

وَكَذَلِكَ نُوَلِّي بَعْضَ الظَّالِمِينَ بَعْضًا بِمَا كَانُواْ يَكْسِبُونَ
[6:129]
And thus do We make some of the iniquitous to befriend others on account of what they earned.
Thus do we make the wrong-doers turn to each other, because of what they earn.
Thus We let some of the wrong-doers have power over others because of what they are wont to earn.