Egypt crisis: Morsi accused of plotting with Hamas
Ousted Egyptian President Mohammed Morsi is being held over allegations of links with Palestinian militants Hamas and plotting attacks on jails in the 2011 uprising, it has been announced.
He is to be questioned for an initial 15-day period, a judicial order said.
Tens of thousands of people are attending rallies for and against Mr Morsi in different parts of Cairo.
Clashes broke out both in the capital and between rival protesters in the country's second city, Alexandria.
The order issued on Friday is the first official statement on Mr Morsi's judicial status since he was overthrown.
He has been held at an undisclosed location since his removal by the military on 3 July.
Since Mr Morsi, the country's first democratically elected president, was ousted, dozens of people have died in clashes between his supporters and opponents. Militants have also staged deadly attacks in the Sinai peninsula.
The army chief, Gen Abdel Fattah al-Sisi, has called on people to take to the streets to give the military a mandate to confront violence and "terrorism".
The judicial order says the former president is suspected of conspiring with Hamas, which rules the Gaza Strip and has strong links with Mr Morsi's Muslim Brotherhood, during the uprising against former President Hosni Mubarak.
He is accused of colluding with the Palestinian group to storm police stations and jails, "setting fire to one prison and enabling inmates to flee, including himself, as well as premeditated killing of officers, soldiers and prisoners".
Mr Morsi and several Muslim Brotherhood leaders were freed during a breakout at a Cairo prison in January 2011.
The BBC's Jim Muir in the Egyptian capital says the order provides legal cover for the continued detention at a time when the UN and Western powers are calling for the ousted president to be released or properly charged.
A spokesman for the Muslim Brotherhood, Gehad el-Haddad, described the accusations as "ridiculous". He told Reuters news agency that the order marked the return of the "old regime".
Hamas itself said there was not a shred of evidence of its involvement in the prison break.
Eleven people were injured in clashes between rival groups in Cairo's Shubra district, security sources say. They appear to have involved stone-throwing.
In Alexandria, stones were thrown when Morsi and Sisi supporters confronted each other after Muslim Friday prayers. A number of people were injured.
A huge crowd of Morsi supporters has filled streets around Cairo's Rabaa al-Adawiya mosque, where they have been holding a sit-in protest.
"Sisi out! Morsi is president! Down with the army!" they could be heard chanting.
El-Baz Abu Maati, a protester who travelled to Cairo from the Nile Delta city of Mansura, told AFP news agency: "I am here to support the real president of Egypt, we are going to protest here peacefully."
Correspondents say the mood among the Morsi supporters has been calm and stewards have been searching demonstrators to ensure no weapons are brought to the rally.
The clashes which resulted in casualties broke out
Tens of thousands of army supporters have gathered on Tahrir Square, the traditional focus for mass rallies in Cairo.
"The people, the source of all power, mandate the army and police to purge terrorism," read a giant banner stretched across one entrance to the square. Many people carried posters of Gen Sisi.
The Tamarod movement that organised protests which preceded Mr Morsi's removal has urged its supporters to turn out on Friday to show support for the military.
Mr Morsi narrowly won the presidential election in June 2012 but his opponents accused him of trying to impose an Islamist agenda on the country.
Interim President Adly Mansour has set out a "roadmap" towards a revision of the constitution introduced by Mr Morsi and for fresh elections in early 2014, but this has has been rejected by the Muslim Brotherhood.
Hisham Qandil, who was prime minister under Mr Morsi proposed his own roadmap on Thursday, but there was no official response to his suggestions.
Military spokesmen have previously given the Muslim Brotherhood a deadline of Saturday to join the official process.