The divide seemed as great as the legendary river that runs through this city. On the winning side, there were celebratory fireworks and giddy gridlock, as young women hung out of cars waving flags while their boyfriends blared their horns. On the losing side, there were gunshots and confused crowds of bearded men, seething with anger.

Both sides of the Egyptian divide used the same words, swearing allegiance to “democracy” and claiming “legitimacy,” but it was as if they were speaking different languages. One side’s “military coup” was the other’s “popular uprising.”

At a rally organized by the Muslim Brotherhood in front of the Rabia al-Adawiya mosque, tens of thousands of Egyptians who believe that Islam should stand at the center of political life had camped out since Friday. The crowds stood silent to listen to a brief speech by the head of the armed forces, Gen. Abdel Fatah al-Sissi, who announced the ousting of Islamist President Mohamed Morsi.

Halfway through Sissi’s statement, the men, many wearing construction workers’ hard hats, began shouting, “Down with the army!” and banging wooden clubs and metal pipes they had carried. Some threw rocks toward an apartment block that housed army officers. Within minutes, shots were fired and panicked men began running in fear down alleyways and through gardens.

In the aftermath of Sissi’s announcement, the Egyptian military quickly began unspooling coils of concertina wire and blocking streets with rows of armored personnel carriers to prevent the Brotherhood rally from growing — and participants from leaving.

Soon, the military began taking news channels tied to the Brotherhood and other Islamic groups off the air. Reports also swirled about a raid on the offices of the al-Jazeera television network.

Just a few miles away, crowds filled Tahrir Square to overflowing, fireworks lit up the sky for hours, and revelers hugged one another and wept with happiness and relief.

“We supported Morsi at the beginning,” recalled Ahmed el-Shennawy, a certified public accountant. “But he is a loser.”

Shennawy was waving an Egyptian flag on a second-story balcony, and he boasted that crowds like these had not been seen since “Adam’s time” at the dawn of humankind. His son, Mohamad, said simply, “I am speechless.”

At the pro-Morsi rally, Ahmed Enaba, a Cairo electrician, expressed shock at the speed with which the Egyptian military decided to sweep Morsi aside.

“This is a war against political Islam,” he said. “And so it must be the work of the Americans and the Zionists,” a reference to Israel.

“But it is not important because we will prevail,” Enaba said. He said a military coup would be a kind of “political suicide” for the Egyptian army.

Alaa Hassam, a civil servant in Cairo, warned that the ousting of Morsi would “turn the whole country into another Syria.”

Asked whether this meant Egyptians attacking each other, Hassam said, “No, we will not fight the liberals and the secular. We will fight the army.”