Tens of thousands of people rallied in Cairo on Friday, some of them in response to a call by the army chief to "fight terrorism", others in support of deposed president Mohamed Morsi, in protests that will only further deepen the country's political divisions.

The protests in Cairo remained largely peaceful, but at least five people were killed in clashes in the northern city of Alexandria, according to the interior ministry.

Defence minister Abdel Fattah el-Sisi called for the pro-army rallies in a speech on Wednesday, saying a large turnout would give the army a mandate to stop "violence and terrorism".

Tens of thousands of people answered his call, turning out in perhaps the largest numbers since nationwide protests that led to Morsi's removal earlier this month. Crowds filled Cairo's iconic Tahrir Square and outside the presidential palace, and gathered in governorates across Egypt as well.

"The people, the source of all power, mandate the army and police to purge terrorism," read a banner stretched across the entrance to Tahrir.

Tanks guarded the entrance to the square, military helicopters buzzed overhead, and police officers mingled with the crowd, posing for photographs. It was all a far cry from the usual scene over the past two-and-a-half years, when protesters in Tahrir routinely clashed with police and denounced the army.

"The army are here to protect the people, they don't lie," said Ezzat Fahmi, 38, who said Sisi called the rallies "to show the entire world that the Egyptian people don't want the [Muslim] Brotherhood anymore."

Leaders of Tamarod, the petition campaign that collected signatures calling for Morsi's ouster, endorsed Friday's protests, enouraging their supporters to help "cleanse Egypt". But some revolutionary movements, including the April 6 youth movement, rejected Sisi's call for rallies.

'The dictatorial police state'

Morsi's Muslim Brotherhood and its remaining political allies had been planning their own mass rallies for more than a week.

Thousands of their supporters gathered outside of a mosque in the Nasr City district, and near Cairo University, both the sites of ongoing protests since Morsi's ouster.

"He is fueling more anger from one sector against another sector," said Maged Osman, a 25-year-old Morsi supporter, referring to Sisi's call for protests.

The pro-army rallies were intended to overwhelm the pro-Morsi crowd's numbers and demonstrate public support for the army. It has also raised fears - and hopes, among some Egyptians - that the army is planning a major crackdown on the Brotherhood.

"It is either victory over the coup or martyrdom," said Mohamed el-Beltagy, a leading member of the Muslim Brotherhood, in a speech to the crowds.

Earlier on Friday, the state news agency reported that Morsi is being held for 15 days while prosecutors investigate claims that he conspired with the Palestinian group Hamas to carry out attacks during Egypt's 2011 revolution.

A spokesman for the Brotherhood said the charges showed the "complete bankruptcy of the leaders of the bloody coup."

Egyptians "reject the return of the dictatorial police state and all the repression, tyranny and theft it entails," Ahmed Aref said in a statement.

Jen Psaki, a spokeswoman for the US state department, expressed concern about the investigation. "I can't speak to the specific charges. But we do believe that it is important that there be a process to work toward his release," she said.

Pro- and anti-military protesters clashed in Alexandria, outside the Qaid Ibrahim mosque, often a flashpoint for demonstrations. Five people were killed and nearly 150 were injured, the health ministry said, mostly by birdshot and stab wounds.

There were also brief clashes in Shubra, a neighbourhood in central Cairo, when pro- and anti-Morsi demonstrators crossed paths and threw rocks at each other. Ten people were injured.