BEIRUT — Arab leaders from Saudi Arabia to Syria rushed Thursday to congratulate Egypt for deposing its elected Muslim Brotherhood president, signaling a rare moment of unity in the divided and still overwhelmingly undemocratic region.

The enthusiastic response to the Egyptian military’s ouster of President Mohamed Morsiunderscored the extent to which the Islamist leader had failed to win allies abroad, much as he had at home, alienating Egypt’s traditional friends and foes alike with an often erratic foreign policy.