Protesters have returned to Cairo's Tahrir Square following a ruling by Egypt's Supreme Constitutional Court that the parliamentary elections held last year were "illegitimate".

The court said the parliament would have to be dissolved and new elections held.

The decision is seen as a blow to the Muslim Brotherhood, which won a majority in the elections and may lose seats in a re-run.

In a separate ruling, the court decided that former prime minister Ahmed Shafiq could continue to contest this weekend's run-off in the presidential election against the Brotherhood's Mohamed Morsy.

It rejected as unconstitutional a law that would have barred Mr Shafiq from standing.

The Muslim Brotherhood said the court rulings indicated Egypt was heading into "very difficult days that might be more dangerous than the last days of Mubarak's rule".

"All the democratic gains of the revolution could be wiped out and overturned with the handing of power to one of the symbols of the previous era," it said.

The parliamentary vote had swept long repressed Islamists into a commanding position in the legislature.

It was a feat the Muslim Brotherhood had aimed to repeat with their candidate in Saturday and Sunday's presidential vote.

Meanwhile, Mr Morsy pledged to press ahead with his presidential bid regardless and warned against foul play of the type that was typical of elections in Mubarak's days.

Mr Shafik, a former military man appointed premier in the last days of Hosni Mubarak's rule, hailed the rulings as "historic".

Outside the constitutional court, protesters chanted "Down, down with military rule" and hurled stones at troops lined up in a security cordon. A few hundred also gathered in Tahrir Square.

US Secretary of State Hillary Clinton said the United States expected Egypt's military authorities to fully transfer power to a democratically elected civilian government.

"There can be no going back on the democratic transition called for by the Egyptian people," Mrs Clinton told reporters, declining specific comment about the court ruling.

Hundreds have also taken to the streets in Egypt's second city Alexandria to condemn a move by the constitutional court to dissolve the lower house of parliament.