The law, which was passed by the People's Assembly in April and later approved by the ruling military council, prevents former senior officials who served the former leadership in the last ten years, from exercising political rights.
Shafiq, who was the last prime minister under ex-President Hosni Mubarak, will face Muslim Brotherhood's candidate Mohamed Morsi in the run-off of the presidential election on Saturday and Sunday. But protesters have recently been urging to ban him from running in the vote.
Meanwhile, the same court on Thursday ruled unconstitutional some articles related to the parliament election law, which allow party members to compete for independents seats.
The parliamentary law, which was initially approved by the ruling military council in July last year, underwent several amendments under the pressure of political powers. The changes raised the number of seats contested by parties from one half of the total, to two thirds, while one third were reserved for independents. But finally parties were allowed to run for all seats in the electoral process.
Enabling party candidates to run for independents seats, unfairly gave the advantage to candidates who had the support of their parties, the court explained.
The elections were run in line with legal articles which have since been deemed unconstitutional, thus rendering the whole parliament void and leading to its dissolution, it added.
The court said the parliament-issued laws will remain active and applicable despite the ruling until further verdicts are made.
"The verdicts of the constitutional court today means that the ruling military makes a complete coup," said Mohamed al-Beltagy, the People's Assembly member of the Muslim Brotherhood's Freedom and Justice Party.
Deputy Head of the Constitutional Court Maher Sami said the verdict meant the whole People's Assembly was dissolved.
"Dissolving the parliament gets the state in a dark tunnel," said Deputy Head of the Freedom and Justice Party Essam al-Erian.
Meanwhile, the Wafd Party announced on its website that it began planning for the coming parliament elections.
Hundreds of protestors flocked to Tahrir Square in downtown Cairo to express their objection against the rulings.
"That's enough for corruption, Shafiq must be isolated," the protestors shouted.
"The Egyptians will isolate the former regime remnants themselves by the voting boxes," the Freedom and Justice Party said on its website, calling the people to vote for their candidate Mohamed Morsi.
Shafiq, for his part, described the court's rulings as " historical."
"Today's verdict legalized my right to run in the presidential elections, which means the era of revenges and tailor-made laws has passed away," Shafiq said.
"From now on one can think the state's institutions may be used to achieve purposes against specific persons," he added.
Freedom and Justice Party presidential candidate Mohamed Morsi said his party respected the judiciary rules, but they have concerns on the "timing" of the verdict.
"The timing of the verdict isn't suitable, as it was announced 48 hours before the run-off," Morsi said to private Egyptian Dream TV channel in an interview after the verdicts.
The ruling military council affirmed that the presidential elections run-off will be held on Saturday and Sunday as scheduled.