An Egyptian judge ordered the detention of toppled president Mohammed Morsi to be extended as the country braced for mass rallies.

Authorities said that Morsi woulde be held as an investigation into his alleged contacts with Hamas to help in his escape from prison in 2011 was under way, state news agency Mena reported.

Morsi has been held in an undiscolsed location since 3 July, after he was ousted by the military in the wake of mass street demonstrations. Mena indicated he had been interrogated.

The interim government alleged that Morsi collaborated with the Palestinian group "to carry out anti-state acts, attacking police stations, army officers and storming prisons, setting fire to one prison and enabling inmates to flee, including himself, as well as premeditated killing of officers , soldiers and prisoners".

He escaped with dozens of senior Muslim Brotherhood during the uprising that toppled President Hosni Mubarak in 2011.

News of his continued detention was likely to risk reigniting violence, said political observers. Morsi's Muslim Brotherhood supporters were expected to the streets at the same time as a demonstration called by the man who deposed their leader, military strongman Gen Abdel-Fatah el-Sissi.

He had called on people to protest against "violence and terrorism" as a way of backing the coup.

Military spokesman Col Ahmed Mohammed Ali added that the army was ready to tackle opponents "decisively and with force".

"We reaffirm that the Egyptian armed forces never uses its weapons against its own people but will do so against violence and black terrorism which has no faith and no nation," a statement on a military-affiliated Facebook page read.

The Brotherhood's spiritual leader, Mohammed Badie, said ousting Morsi was worse than destroying the Kaaba, Islam's holiest site.

In an attempt to cool things down, leaflets were dropped on Morsi supporters outside the Rabaah al-Adawiya Mosque.

"We are not against you so don't be against us. Don't raise your weapons in the face of your brothers, don't destroy, don't burn, and let us all be together against killing, violence and terrorism," the leaflets said.