New Pakistani PM Yusuf Raza Gillani has said he will order the release of all judges detained under emergency rule, minutes after being elected by MPs.
President Pervez Musharraf in November sacked dozens of judges as the Supreme Court was set to rule on whether his re-election was legal.
Former chief justice Iftikhar Chaudhry was among those still held.
Mr Gillani's Pakistan People's Party heads a government for the first time in 12 years after February's elections.
It will lead a coalition that has a substantial majority.
Mr Gillani won the parliamentary vote by 264 votes to the 42 of Musharraf ally Chaudhry Pervez Elahi.
Mr Gillani made two key pledges in his speech following his election.
The first was to demand "the immediate release of all the arrested judges", sparking cheers from most of the gathered MPs.
Police quickly removed barbed wire from outside Mr Chaudhry's home in Islamabad, where he was under house arrest.
Mr Chaudhry later appeared on his balcony to wave to hundreds of supporters. It was his first public appearance for four months.
He thanked his "fellow judges and the entire nation".
"I have no words to express my gratitude to the way you have struggled... to reach this day," he said.
Iftikhar Chaudhry made his first public appearance for four months
State media have quoted an unnamed senior Islamabad administrator as saying that "all deposed judges are free to move".
One of the judges who was under house arrest, Khalil ur-Rehman Ramday, said supporters were in his home within 10 minutes of Mr Gillani's vow.
"They took me out in a procession... for about five minutes. And I think the arrest... it's been called off."
Mr Gillani's second pledge was to seek a resolution calling for a UN investigation into the assassination of former Prime Minister Benazir Bhutto.
"Democracy has been revived due to the sacrifice of Benazir Bhutto," Mr Gillani said.
He urged MPs to help him in his tasks:
"My past experience in parliament has shown me that if you want this country to work, the parliament must be supreme, constitution must be sacred and rule of law enforced."
The BBC's Syed Shoaib Hasan in Islamabad says Mr Gillani is much admired within the PPP. He resisted pressure from President Musharraf to desert the party, refusing to do any deals with him.
Mr Musharraf (R) was badly weakened by the February elections
The former parliamentary speaker went to jail in 2001, serving five years following a conviction over illegal government appointments.
The sentence was passed by an anti-corruption court formed by President Musharraf as part of what he termed measures to cleanse politics.
His opponents say it was a means of intimidating and coercing their members to join his government.
Mr Gillani will have the daunting task of holding together a large coalition, tackling Islamic militancy and severe economic problems.
The PPP, led by Benazir Bhutto until her assassination in December, emerged as the biggest party in the February elections.
It is now headed by her widower, Asif Ali Zardari.
On Monday he was quoted in The News newspaper as saying that Mr Gillani would serve a full five-year term as prime minister.
There has been widespread speculation that Mr Zardari only wants the next prime minister to hold the post on an interim basis while Mr Zardari takes the necessary steps to make himself eligible to become prime minister.
That would include Mr Zardari winning a parliamentary seat in a by-election.