CAIRO—The leader of Egypt's military ousted President Mohammed Morsi from office and replaced him with the head of the country's constitutional court—a move the presidential palace quickly branded a "complete military coup."

The announcements capped days of political crisis that brought millions of Egyptians out to the country's streets, spurring bellicose rhetoric from Mr. Morsi's backers and Egypt's military, and sparking deadly violence. More than two years after the biggest early tremor of the Arab Spring ousted...