The Messenger of Allah ﷺ said, "Help your brother, whether he is the oppressor or the oppressed."The companions asked, "Messenger of Allah, we understand helping him when he is oppressed, but how do we help him when he is the oppressor?"He replied, "By restraining his hand."
قال رسول الله ﷺ: انصر أخاك ظالما أو مظلوما قالوا: يا رسول الله، هذا ننصره مظلوما فكيف ننصره ظالما؟ قال: تأخذ فوق يديه
Bukhari narrated it in the chapter on Injustices (2244), from Musaddad, who said, Mutamir narrated to us, from Humayd, from Anas, who said, then he mentioned it. And His saying, "And be just. Indeed, Allah loves those who are just" [Hujurat 49:9].