Sayyiduna Abu Hurayrah (may Allah be pleased with him) said that the Prophet (peace and blessings be upon him) said: "Jihad is obligatory upon you along with every ruler, whether he is righteous or wicked, even if he commits major sins; and the funeral prayer is obligatory over every Muslim, whether he is righteous or wicked, even if he commits major sins."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب قتال أهل البغي / 16770