Egypt's Islamist-led parliament reconvened on Tuesday in an open challenge to the generals who dissolved it last month.
The supreme court swiftly ruled the newly elected, Islamist president had acted illegally in summoning the assembly, heightening a confrontation between the newly elected head of state and an establishment that once served Hosni Mubarak.
The legislature, dominated by President Mohamed Mursi's Muslim Brotherhood and allies, was dismissed by the army in line with a Supreme Constitutional Court ruling last month, days before Mursi's election. Mursi, the first civilian leader to lead Egypt in 60 years, ordered parliament's recall on Sunday.
In a sign the standoff would not end swiftly, Brotherhood officials were quick on Tuesday to question the court's right to rule against the president's decree and vowing to fight on.
"I invited you to convene in accordance with the decree issued by the president," said parliament speaker Saad al-Katatni, a Brotherhood man like Mursi, had told parliament.
But many liberal groups - heavily outnumbered by Islamists in parliament - boycotted Tuesday's session, saying Mursi's decree was a violation of the powers of the judiciary.
Then, just hours after lawmakers gathered, the supreme court issued a fresh order: "The court ruled to halt the president's decision to recall the parliament," Maher el-Beheiry, the court's chief justice, said.
Egypt's troubled transition to democracy is increasingly being fought in the courts, but that masks a much deeper conflict with an establishment rooted in six decades of military rule, half of that period under the leadership of Mubarak.
Senior Brotherhood official Mahmoud Ghozlan said the latest court ruling was linked to the army: "It is part of a power struggle between the military council and the president who represents the people and in which the military council is using the law and the judiciary to impose its will," he told Reuters.
In a war of attrition that may play out over years, Islamists long suppressed by Mubarak and his military predecessors are seeking to push generals out of politics and reform a wider establishment still filled with Mubarak-era officials.
The Brotherhood signalled it would not retreat.
Presidential legal adviser Mohamed Fouad Gadallah told Al-Ahram newspaper's website it was "not within the competences of the constitutional court" to assess the president's decree.
Brotherhood lawyer Abdel Moneim Abdel Maqsoud said his group respected the law: "But we also confirm we will continue to fight in all ways to defend what is right," he said.
A member of the Brotherhood's Freedom and Justice Party, Ahmed Abu Baraka, called the court ruling "political thuggery".
Parliament was elected in six weeks of voting that ended in January, under a complex procedure which the Supreme Constitutional Court ruled on June 14 was unconstitutional, declaring the lower house void. The then-ruling military said that meant parliament had to be dissolved. But Mursi's backers say it should be allowed to work until early elections are held.
Mursi appeared to have stolen a march on the army, in their first skirmish. But the court ruling indicated the long campaign he will have to fight in courts, with both sides seeking to exploit deep political divisions in the nation of 82 million.
"It is a dangerous game," said Hassan Nafaa, a professor of political science who was an active opponent of Mubarak's rule and backed protests that ousted him. "I hope there will be some political solution to that crisis by direct negotiations between the president and the Supreme Council of the Armed Forces."
Aside from rival statements issued by the Brotherhood and the army, there has been no public sign of a clash. Mursi and SCAF chief Field Marshal Hussein Tantawi, who ruled the country in the interim after Mubarak quit, have seemed relaxed together at public events before and since the president's decree.
In an air force graduation ceremony shown on live television on Tuesday, display aircraft left a vapour trail shaped like a heart in the sky for the dignitaries, prompting a big smile from Chief of Staff Sami Enan and a hesitant smirk from Mursi, who was seated between Enan and Tantawi.
How the dust settles in Egypt will have repercussions across a region where Islamists, many inspired by the Brotherhood, have emerged as powerful actors in revolts that toppled autocrats in Tunisia and Libya, and a rebellion still being fought in Syria.
Generals sought to rein in the new president's powers in a last-minute election day decree. But short of staging a coup - a move seen by most analysts as unlikely and certain to unite Islamists and their secular rivals - Egypt's army has limited room to manoeuvre since handing executive office to Mursi.
The military is now reliant on favourable rulings from judges - known to have a strong anti-Islamist streak, but, like the rest of Egypt, also divided. Rulings in the Supreme Constitutional Court so far have played in their favour.
Generals can maintain influence by negotiating quietly with the Brotherhood behind the scenes. They met regularly during the transition, although Western diplomats say relations became increasingly tense, particularly when the Brotherhood made a U-turn on an earlier pledge not to seek the presidency.
Dialogue is clearly the tactic urged by the West and liberal politicians.
"The national conscience demands an immediate meeting between the president, representatives of the legislature and the military council to reach a political and legal solution to avoid the country exploding," reformist politician Mohamed ElBaradei wrote on Facebook as parliament met.
U.S. Secretary of State Hillary Clinton said: "We strongly urge dialogue and concerted effort on the part of all to try to deal with the problems that are understandable but have to be resolved in order to avoid any kind of difficulties that could derail the transition that is going on."
Western states, long wary of political Islam but now seeking to engage with the Brotherhood, have watched Egypt's turmoil closely, in particular the United States, concerned about the stability of the first Arab nation to make peace with Israel.
Clinton, whose country gives Egypt's military $1.3 billion in aid each year, meets Mursi when she visits Egypt on July 14.
On Monday, the army defended its dissolution of parliament, saying it had had to respect the court's first ruling. In an apparent swipe at the president, it said it was confident "all state institutions" would respect the constitution and the law.
Nevertheless, the army did not take any steps to prevent lawmakers from entering parliament.
More battles lie ahead, such as a debate over the writing of a new constitution. The army, in its decree last month, gave itself the right to form a new constitution-writing body if the one picked by parliament hits an obstacle. An earlier constituent assembly was dissolved by a court.
Dozens of legal cases are now before a range of courts over issues including Mursi's decree, the validity of the constitutional assembly and the election of the upper house.
The Brotherhood says it is seeking a way to comply with the supreme court's ruling without dissolving the legislature.
Parliament voted to send a list of members to a court of appeal to determine whether or not they should continue to sit in the chamber, setting the stage for a new legal battle.
(Reporting by Dina Zayed, Omar Fahmy and Marwa Awad; Writing by Edmund Blair; Editing by Peter Graff and Alastair Macdonald)