Sahih Bukhari Volume 4, Book 52, Hadith Number 204.

Narated By Abu Huraira : That heard Allah’s Apostle saying, “We are the last but will be the foremost to enter Paradise).” The Prophet added, “He who obeys me, obeys Allah, and he who disobeys me, disobeys Allah. He who obeys the chief, obeys me, and he who disobeys the chief, disobeys me. The Imam is like a shelter for whose safety the Muslims should fight and where they should seek protection. If the Imam orders people with righteousness and rules justly, then he will be rewarded for that, and if he does the opposite, he will be responsible for that.”