Imam Ahmad (may Allah have mercy on him) used to say, “If I knew that one of my prayers would certainly be answered, I would devote it to the ruler.”
During the ordeal he faced, Imam Ahmad remained patient; never was it authentically reported that he supplicated against the authorities or spoke ill of them. He persevered, and in the end he prevailed—this is the approach of Ahl al-Sunnah wa-l-Jamaʿah.
Therefore, those who pray against the Muslim rulers are not upon the path of Ahl al-Sunnah wa-l-Jamaʿah, and the same applies to those who neglect to pray for them. Such behavior betrays a deviation from the creed of Ahl al-Sunnah wa-l-Jamaʿah.
Some people even condemn those who, in the Friday sermon, supplicate for the rulers, accusing them of flattery, hypocrisy, or currying favor. Exalted is Allah! This very practice is the way of Ahl al-Sunnah wa-l-Jamaʿah. Indeed, it is part of the Sunnah to pray for the rulers, for when they are upright the people follow suit. You therefore ask Allah to grant them rectitude, guidance, and goodness. Even if they have faults, as long as they remain within Islam they still possess some good. So long as they judge by the law, enforce the prescribed penalties, safeguard security, protect the Muslims from aggression, and deter the unbelievers, this is a tremendous benefit for which we pray on their behalf. Whatever sins or open wrongdoing they may commit is upon them, yet the greater good they bring warrants that we ask Allah to set them straight and grant them righteousness—and this is the method of Ahl al-Sunnah wa-l-Jamaʿah.