It is narrated from Sayyiduna Amr al-Bikali (may Allah be pleased with him); he said: I heard the Messenger of Allah (peace and blessings be upon him) say: "When you have rulers over you who command you to pray, to pay zakah and to perform jihad, then Allah has forbidden you to revile them and has made it lawful for you to pray behind them."
Hadith Referenceالمعجم الكبير للطبراني / باب العين / 14162