"Today, democracy has been restored thanks to the great sacrifice of Benazir Bhutto," Gilani said in his first address to the assembly. "I invite all political forces to join us because the country is facing such a crisis that a single man cannot save it."
Minutes after Gilani's election, Chief Justice Iftikhar Mohammed Chaudhry made an appearance on the balcony of his home after months of house arrest imposed by Musharraf. Gilani said he would order the immediate release of Chaudhry and dozens of other judges detained after a state of emergency was declared in November.
Pakistan's state-run news agency reported that all judges were freed, according to the prime minister's orders.
The new government has promised to put Chaudhry and other judges back on the bench within 30 days -- a move that could intensify a power struggle with Musharraf, a former army chief who seized power in a 1999 coup.
"This is the dawn of a new era. It's the end of dictatorship in this country," said Athar Minallah, a lawyer close to Chaudhry, according to news services.
Musharraf removed the judges after it appeared that the Supreme Court would overturn his re-election as president in October. He stepped down as the country's military leader in November under opposition party pressure before he was sworn in for his third term as president.
If all the judges are reinstated, they are expected to pursue legal challenges to Musharraf's rule.
"I have no words to thank you for the way you struggled for nearly five months for the enforcement of the rule of law and our constitution," Chaudhry told a crowd of supporters from his balcony, according to the Associated Press.
Gilani said his government would strengthen the judiciary and parliament and has called for the repeal of Musharraf-backed constitutional changes that consolidate his grip on power.
"If we have to make this country successful then we will have to make parliament supreme, we will have to respect the constitution and uphold the rule of law," Gilani said.
Gilani, who was a close aide to Bhutto and is a former National Assembly speaker, was jailed by Musharraf from 2001 to 2006 on corruption charges. He won with the support of Bhutto's Pakistan People's Party and its coalition partners, including the party of another former prime minister, Nawaz Sharif.
Opposition parties routed Musharraf's ruling Pakistan Muslim League-Q party in February general elections and the PPP's coalition has almost secured a two-thirds majority needed to amend the constitution.
Musharraf pledged full support for the coalition on Sunday calling it the start of a "real democratic era."
Gilani is scheduled to be sworn in on Tuesday by Musharraf and will begin building his cabinet this week. He said his first act would be to seek a U.N. investigation into Bhutto's death during a suicide bomb attack in December.
Giliani will head a government facing mounting economic problems, including soaring inflation, power shortages and slumping foreign investment.