Several hundred people gathered in Cairo's Tahrir Square after the rulings to denounce the action and rally against Shafiq, the presidential candidate seen by critics as a symbol of Mubarak's autocratic rule. But with no calls by the Brotherhood or other groups for massive demonstrations, the crowd did not grow.
Activists who engineered Egypt's uprising have long suspected that the generals would try to cling to power, explaining that after 60 years as the nation's single most dominant institution, the military would be reluctant to surrender its authority or leave its economic empire to civilian scrutiny.
Shafiq's rival in the Saturday-Sunday runoff, Mohammed Morsi of the Muslim Brotherhood, said he was unhappy about the rulings but accepted them.
"It is my duty as the future president of Egypt, God willing, to separate between the state's authorities and accept the rulings," the U.S.-trained engineer said in a television interview. Late Thursday, he told a news conference: "Millions will go to the ballot boxes on Saturday and Sunday to say 'no' to the tyrants."
Senior Brotherhood leader and lawmaker Mohammed el-Beltagy was less diplomatic, saying the judges' action amounted to a "full-fledged coup."
"This is the Egypt that Shafiq and the military council want and which I will not accept no matter how dear the price is," he wrote on his Facebook page.
Equally blunt was another Brotherhood stalwart, lawmaker Subhi Saleh. "The court, I can say, has handed Egypt to the military council on a golden platter and free of charge too," he said.
In last year's parliamentary elections Egypt's first democratic ones in generations the Brotherhood became the biggest party in the legislature, with nearly half the seats, alongside more conservative Islamists who took another 20 percent. It is hoping to win the presidency as well.
The rulings, however, take away the Brotherhood's power base in parliament and boost Shafiq at a time when the Islamists are at sharp odds with a wide array of major forces, including the military, the judiciary and pro-democracy groups behind the uprising.
The court also derailed the broader transition to democracy, said rights activist Hossam Bahgat.
"The military placed all powers in its hands. The entire process has been undermined beyond repair," Bahgat said. "They now have the legislative and the executive powers in their hands and there is a big likelihood that the military-backed candidate (Shafiq) is going to win. It is a soft military coup that unfortunately many people will support out of fear of an Islamist takeover of the state."
On Wednesday, the military-appointed government gave security forces the right to arrest civilians for a range of vague crimes such as disrupting traffic and the economy that would give it a mandate to crack down on protests. Many saw the move as evidence that the generals aim to stay in power beyond the July 1 deadline they announced for handing it over to a civilian president.
All day Thursday, military armored vehicles circulated through Cairo's streets playing patriotic songs as soldiers passed out leaflets urging passers-by to vote in the runoff election. Plastered on the side of their vehicles were posters saying "the army and the people are one hand."
After the court's decision was announced, a visibly energized Shafiq spoke at a rally that had the trappings of a victory celebration. Supporters chanted "We love you, Mr. President," and the 70-year-old candidate blew kisses to them. In his address, he praised the military and said he hoped for a dramatic change in the makeup of the next parliament.
"We want a parliament that realistically represents all segments of the Egyptian people and a civil state whose borders and legitimacy are protected by our valiant armed forces," said Shafiq, a longtime friend and self-confessed admirer of Mubarak.
The presidential race has already deeply polarized the country.
Shafiq's opponents view him as an extension of Mubarak's authoritarian regime. Morsi's critics fears he and the Brotherhood will turn Egypt into an Islamic state and curtail freedom. Leftist, liberal and secular forces who launched the pro-democracy uprising bemoaned the choice, and some talked of a boycott.
Now they and the Brotherhood accused the military of using the court to change the rules of the game.
In its ruling, the court said a third of the legislature was elected illegally, and as a result, "the makeup of the entire chamber is illegal and, consequently, it does not legally stand."
The explanation was carried by Egypt's official news agency and confirmed to The Associated Press by one of the court's judges, Maher Sami Youssef.
The law governing the parliamentary elections was ruled unconstitutional by a lower court because it breached the principle of equality when it allowed party members to contest a third of the seats set aside for independents. The remaining two-thirds were contested by party slates.
In a separate ruling, the court said Shafiq could stay in the runoff election, rejecting a law passed by parliament last month that barred prominent figures from the old regime from running for office.
Mubarak was sentenced to life in prison on June 2 for failing to prevent the killing of some 900 protesters during the uprising. About three dozen figures from his regime are also in prison, either charged with or convicted of corruption.
Defenders of the law argued that after a revolution aimed at removing Mubarak, parliament had a right to prevent regime members from returning to power. The law's opponents called it political revenge targeting Shafiq. The court said the law was not based on "objective grounds" and was discriminatory, violating "the principle of equality."
"This historic ruling sends the message that the era of score-settling and tailor-made law is over," Shafiq said at his rally.
Now, elections will have to be organized to choose a new parliament, and the Brotherhood is in a weaker position than it was during its powerful showing in the first election, held over three months starting in November 2011.
After its election victory, the Brotherhood tried to translate those gains into governing power but was repeatedly stymied by the military.
At the same time, there has been widespread public dissatisfaction with the Islamist-led parliament, which many criticized as ineffective. The Brotherhood's popularity has also declined because of moves that critics saw as attempts to monopolize the political scene and advance its own power. It angered liberals, leftists and secular Egyptians when it and other Islamists tried to dominate a parliament-created panel writing a new constitution. The panel was dissolved by court order, and a second one was selected by parliament in a process that was boycotted by liberals who accused the Brotherhood of packing it with Islamists, as they did with the first one.
The dissolution of parliament now raises the possibility that the military council could appoint the panel, a step that would fuel accusations that it is hijacking the process.
The legal adviser of the Freedom and Justice Party, the Brotherhood's political arm, said the court rulings were "political," lamenting the outgoing legislature as the country's "only legitimate and elected body."
"They are hoping to hand it over to Ahmed Shafiq and make him the only legal authority in the absence of parliament. The people will not accept this and we will isolate the toppled regime," Mukhtar el-Ashry said in a posting on the party's website.
A moderate Islamist and a former presidential candidate, Abdel-Moneim Abolfotoh, warned that the pro-democracy groups which engineered the uprising would protest the court's rulings.
"Those who believe that the millions of young people will let this pass are fooling themselves," he wrote on his Twitter account.
Lobna Darwish, an activist and longtime critic of the military, said the rulings showed the entire electoral process was a "distraction" from organizing people in neighborhoods to realize the goals of the uprising.
"The military ended up getting everything and we got nothing," she said.