President Mohamed Morsi has announced a state of emergency in three cities near Egypt's Suez Canal, following four days of civil unrest that have left at least 40 dead and over 500 injured.

Port Said, Suez, and Ismailiya – the cities most affected by the violence – will be subject to a 30-day curfew lasting from 9pm to 6am every night, Morsi said in a surprise televised speech.

Speaking to the Guardian, a spokesman for the opposition expressed frustration at the announcement, blaming the president's policies and inaction for the violence, and arguing that the state of emergency was too little, too late.

Since Thursday, hundreds of thousands of protesters have taken to the streets in 12 of the country's 21 provinces, to protest against the Islamist president, the Muslim Brotherhood, and police brutality – exactly two years after the start of the Egyptian revolution.

On Saturday, the government lost control of Port Said, a coastal city on the Mediterranean, when hardcore football fans rioted in protest at being scapegoated, as they saw it, by security forces for the massacre of over 70 Cairene supporters at a football match in February 2012.

Thirty-seven people died as rioters tried to invade a prison and several police buildings. The situation was inflamed once more on Sunday as police disrupted a funeral march for those killed the day before – sparking yet more upheaval.

"We think the president is totally responsible for the conflict," said Khaled Daoud, a spokesman for the National Salvation Front, a disparate collection of liberal and leftist parties opposed to Morsi's Muslim Brotherhood.

"Almost all over Egypt you're seeing dissatisfaction about the policies of the president," Daoud said. "He only cares about the Muslim Brotherhood."

Daoud also argued that the violence – particularly in Port Said, which was sparked by the long-awaited decision to sentence to death 21 local football fans – was entirely predictable, and therefore very preventable.

Yet as violence broke out last week, Morsi was slow to react publicly, until today. "When the bloodshed happened on [Friday], all the president did was tweet," said Daoud.

Others felt that Morsi had been placed in a difficult position.

According to Elijah Zarwan, a Cairo-based analyst at the European Council for Foreign Relations, the decision to declare a state of emergency certainly risks "inflaming the situation further – blood calls for blood."

Yet the other routes available to Morsi also had their problems, Zarwan told the Guardian.

Instead of calling a state of emergency, Morsi might have placated the Port Said football ultras by involving himself in their court case.

But Zarwan said: "Any political approach he might take to calm the situation in Port Said would risk infuriating a constituency he can ill afford to infuriate, be it football ultras in Cairo, the judiciary, or the police."