His coalition partner had urged him not to, but Sharif stood shoulder-to-shoulder with lawyers at a rally in Lahore, saying "we won't let anyone sit in peace until the judges are restored".
The then Supreme Court chief justice, Iftikhar Chaudhry, and dozens of other judges were purged when Musharraf declared emergency rule last year.
The lawyers have vowed to "lay siege" to parliament unless judges fired by Pervez Musharraf last year get their jobs back.
"If the judges are not restored ... we will lay siege to parliament," a leader of the lawyers' movement, Ali Ahmed Kurd, told the rally of several thousand lawyers and political activists in Lahore.
The protest, called a "long march" even though the lawyers are travelling in a fleet of about 200 vehicles, set off from the southeastern city of Multan on Wednesday. They are due to reach the capital Islamabad on Friday.
The protest is increasing pressure on Musharraf to step down.
Isolated since his allies were trounced in a February election, opponents are demanding he quit and face trial.
Threat to coalition
But it is also a challenge to the two-month-old coalition government led by the party of Benazir Bhutto, the slain former prime minister, as well as a threat to its tenuous unity.
|Sharif, centre, made veiled criticisms |
against his ruling coalition partner [AFP]
Analysts say if Chaudhry were reinstated, he would be expected to take up legal challenges to Musharraf's presidency that could lead to his being ousted.
But the former chief justice may also review an amnesty that wiped out corruption cases against Bhutto, her husband Asif Ali Zardari, who has led her party since she was assassinated in December, and other party politicians.
That, critics say, is why Zardari has been reluctant to restore Chaudhry and his colleagues.
He says he wants to see them get their jobs back as part of a package of constitutional changes that would also strip Musharraf of his powers.
But the package would take months to pass and the lawyers and Zardari's junior coalition partner, Sharif's party, want to see the judges restored immediately through a parliamentary resolution.
Sharif's addressed in Lahore on Thursday was a veiled criticism of Zardari.
"It is so sad and regrettable that even though we have democracy we are still demanding the restoration of the judges," he said.
The uneasy coalition partners are also divided on how to handle Musharraf.
Zardari says he does not recognise Musharraf as a constitutional president and would reduce him to a figurehead under the proposed constitutional changes.
Sharif wants Musharraf impeached and tried for treason.
The coalition has been almost completely preoccupied with the question of the judges and the related issue of Musharraf's fate despite a looming economic crisis and militant threat.
Many ordinary people say they support an independent judiciary, but many are more worried about inflation.