Hundreds of protesters urged Egypt's highest court to bar Hosni Mubarak's former prime minister Ahmed Shafik from high office, two days before he contests a run-off for the presidency.
The Supreme Constitutional Court was meeting to consider the validity of a law passed in April by the Islamist-led parliament that denied political rights to anyone who held a senior post in government or ruling party in the last decade of Mubarak's rule.
Their deliberations add to the suspense around an election that is supposed to seal a transition to democracy after Mubarak was toppled in an Arab Spring uprising last year, but has laid bare deep divisions over how Egypt should be governed.
The law initially prompted the election committee to disqualify Shafik, but he was let back into the race on appeal, pending the court ruling.
A judicial body has already recommended that the law be overturned along with another one that governed the post-Mubarak parliamentary election, which would allow Shafik to continue his bid and possibly dissolving the parliament.
The court is not bound to follow that advice in its verdicts, but legal experts say they expect that it will.
Hundreds of troops and state security conscripts guarded the Cairo court building overlooking the Nile, sealed off by rolls of barbed wire.
The protesters outside demanded that judges sweep Mubarak-era "feloul", or remnants, out of politics, chanting:
"Constitutional court, the feloul are not legitimate."
Haj Sayyed, 71, held up a placard that read: "Scales of justice, weigh carefully - he (Shafik) is a murderer, his lawyer is a feloul and the victim is your mother: Egypt"
The drama is emblematic of the tortuous and messy transition overseen by a council of generals since Mubarak was ousted 16 months ago.
"This sort of overhang is a reflection of our current state of affairs. It's only days before the election and there is legal uncertainty," Judge Mohamed Hamad al-Gamal told Reuters.
A first-round presidential vote last month pushed more moderate candidates out of the race and the choice now facing 50 million eligible voters reflects a society torn between desire for change after six decades of military rule and anxiety over the damage wrought on Egypt by the subsequent political chaos.
"There is no such thing as feloul. We are all Egyptians. No to the plot seeking to divide Egypt," read one banner in Cairo.
Across the street, Shafik campaign posters were spray-painted red to obscure his face.
Lawyer Bahaa Abou Shoka, representing Shafik, said it was unconstitutional to bar a citizen from politics or punish them in any other way without proof of a crime.
"This condition is lacking in the law," Abou Shoka said.
Morsy told the state-owned newspaper al-Ahram that the Brotherhood would respect the court's ruling, and was ready to fight a fresh election.
An administrative court said in February that the rules employed at the last election were unconstitutional. In that vote, two-thirds of seats were allocated to parties and the rest to individuals who were supposed to be independent of any party.
The administrative court judge said political parties should not have been allowed to run for the individual seats. He also said half, rather than a third, of the seats should have been apportioned to individuals.
"If it is proven that the election rules were flawed or unconstitutional, then the entire election process is void," Judge Gamal said. "It would mean that this parliament is unconstitutional, illegitimate and must be dissolved."
Some judicial sources say the constitutional court could delay a ruling on parliament until after the presidential vote.
Under Mubarak, the Supreme Constitutional Court used similar arguments to rule election laws illegal in 1987 and 1990, forcing the dissolution of parliament, overhauls of the electoral system and early elections.