The Messenger of Allah ﷺ said:
سَتَكُونُ أُمَرَاءُ فَتَعْرِفُونَ وَتُنْكِرُونَ فَمَنْ عَرَفَ بَرِئَ وَمَنْ أَنْكَرَ سَلِمَ وَلَكِنْ مَنْ رَضِيَ وَتَابَعَ . قَالُوا أَفَلاَ نُقَاتِلُهُمْ قَالَ لاَ مَا صَلَّوْا
“‘There will be ameers, you recognise (something of what they do) and you reject (some). Whosoever recognised, he would be absolved (of sin) and whosoever rejected, he would be safe. But whosoever accepted and followed (what they do, he would not be safe).’ They (the Sahabah) asked ‘Shouldn’t we fight them?’ He said; ‘No, as long as they pray.’” (Sahih Muslim 1854a)
In the narration that follows it has a slightly different wording:
فَمَنْ كَرِهَ فَقَدْ بَرِئَ وَمَنْ أَنْكَرَ فَقَدْ سَلِمَ وَلَكِنْ مَنْ رَضِيَ وَتَابَعَ
“Whoever hated he would be absolved (of sin) and whoever disapproved he would be safe, but whoever consented and followed (he would be not).” (Sahih Muslim 1854b)
Concerning his ﷺ saying, فمن عرف فقد برئ ‘Whosoever recognised, he would be absolved’ and in the narration which follows it فمن كره فقد برئ ‘Whoever hated he would be absolved’:
As for the narration فمن كره فقد برئ ‘Whoever hated he would be absolved’ it is clear and its meaning is whoever hates the munkar then he is absolved from its sin and its punishment. This is the right of one who is incapable of disavowing with his hand or his tongue, so let him hate it in his heart and be absolved.
As for the narration, فمن عرف فقد برئ ‘Whosoever recognised, he would be absolved’ then its meaning, Allah knows best, is whoever recognises the munkar and is not doubtful about it then it becomes for him a method of absolution from its sin and its punishment. By that he changes it with his hand or his tongue, and indeed the weakest is for him to hate it in his heart.
His ﷺ saying: ولكن من رضي وتابع ‘But whosoever accepted and followed’ its meaning is that the sin and punishment are on whoever accepted and followed. In this is an evidence that whoever is incapable of removing the munkar, there is no sin by his silence. Rather he commits a sin by accepting the munkar or by not hating it with his heart or by following it.
As for his saying: أَلاَ نُقَاتِلُهُمْ قَالَ لاَ مَا صَلَّوْا ‘Shouldn’t we fight them?’ He said; ‘No, as long as they pray’. In it is the meaning of what preceded this, that khurooj (rebellion) is not allowed against the Khulufaa’ due to their oppression or transgression as long as they don’t change anything from the principles of Islam.
Source: Sharh Sahih Muslim, by Imam Nawawi