At least 51 people died in clashes across Egypt as the country's two largest political factions gathered in rival commemorations of Egypt's participation in the 1973 war with Israel, a day of deep significance for many Egyptians.

Both opponents and supporters of the country's ousted president, Mohamed Morsi, rallied in their thousands – ostensibly to mark the 40th anniversary of the Yom Kippur war which is viewed in Cairo as an Egyptian victory, despite ending in a stalemate that favoured Israel.

But rather than emphasising Egypt's unity, the different messages conveyed by each faction's demonstrations underscored divides. Morsi's supporters, whose marches filled highways in west Cairo, used the day to protest against his ousting, while his opponents took to Tahrir Square to praise General Abdel Fattah el-Sisi's role in his overthrow. Deadly violence flared when tens of thousands of Morsi supporters tried to reach Tahrir Square. Soldiers, police and armed vigilantes blocked their path and started firing.

Arriving in west Cairo's Dokki suburb around 3pm, the marchers were met first by teargas, then rubber bullets and then live rounds, according to one witness who was at the front of the march.

"It was three groups of armed people – police, army, and residents – attacking helpless protesters, who didn't even do much to fight back," said Mosa'ab Elshamy, a photographer known for his pictures at Cairo clashes. "Today's march was made up largely of families, lots of women, lots of children. Sometimes marches take things into their own hands, start trouble, break something. But today's march was really remarkably peaceful until the police just shot at them without any kind of trigger."

Some reports suggested that a number of marchers carried firearms, but Elshamy said the protesters, who included hardcore football fans unaffiliated with Morsi's Muslim Brotherhood, simply held their ground for three hours – throwing stones and burning tires – before retreating.

He added: "As a couple of people were running away, they were gunned down, and they left quite a trail of blood."

Opponents of the Muslim Brotherhood argued the Islamists and others had sought a violent response in order to garner sympathy internationally, or to gain concessions during negotiations.

"They are trying to make trouble everywhere so that at some point, the deal will be: fine, stop the trouble, what do you want?" Alaa al-Aswany, one of Egypt's best-known authors and a fierce critic of the Brotherhood, argued in the buildup to the celebrations.

As the day wore on, Cairo became a tale of two Tahrirs – Tahrir Square in the east, where army helicopters flew over pro-military bands, and Tahrir Street in the west, where police and secular locals fired bullets and teargas on the pro-Morsi marches.

The juxtaposition highlighted Egypt's ideological divisions. "Today feels like a second victory," said Mohamed Abdel Aziz, a cleaner wearing a picture of Sisi around his neck. "We feel like we have won our country back from a gang that doesn't belong to Egypt."

Across town, protesters carrying yellow placards – in memory of those who died at several summer massacres of Morsi supporters – had a different idea about what the day meant. "Today is about saying no to the military coup, and bringing back liberty," said Saber Nafi, a pro-Morsi journalist.

What had been a festive afternoon quickly soured, with gangs of vigilantes and plain-clothed policemen in some streets attacking people suspected of being a foreigner, a journalist or a Muslim Brother.

Two liberal politicians – including Khaled Dawoud, a one-time spokesman for Egypt's main secular coalition – were attacked by Brotherhood supporters this weekend. Dawoud was spotted while driving through central Cairo, hauled from his car, and stabbed in his hand and twice in his chest. He is now recovering in hospital.

Clashes were reported in several other neighbourhoods in Cairo and across Egypt, though much of the country remained calm. Some Egyptians expressed frustration at their fellow citizens' overbearing nationalism, and at being pulled between what they feel to be two sides of the same authoritarian coin: the army and the Brotherhood.