The decision to depart the government came after Sharif's Pakistan Muslim League was unable to agree on how to restore the judges with the other main coalition party led by Asif Ali Zardari, the widower of slain opposition leader Benazir Bhutto.
Musharraf fired dozens of judges last year during a time of political turmoil in the country, which led him to declare a state of emergency. The judges were weighing Musharraf's eligibility as president, and he ended up reshaping the Supreme Court and giving up his position of army chief to become a civilian leader.
Sharif and Zardari's Pakistan Peoples Party agree that the judges should be reinstated, but they were unable to settle on terms after three days of talks in London.
Zardari's party wants to link the judges' reinstatement with broader judicial reforms that could restrict the chief justice's tenure, according to the Associated Press. Other legal and political issues, including what to do with the judges installed after the purge, added to the complexity of the matter.
President Musharraf won re-election last year, but his party lost parliamentary elections this year. The two opposition parties led by Sharif and Zardari did not win a majority of seats on their own, so they instead agreed to form a coalition government.
Sharif said Monday he was "very pained" at the decision to withdraw but will still support the coalition government.
"We will sit together for the time being, we are not going to sit on the opposition benches for the time being," he said, quoted the AP. "We will not take any step which will benefit Musharraf's dictatorship."
Zardari's party responded with a conciliatory statement that there is "no doubt that the sacked judges have to be restored ... the only question is how best to do it."
Zardari planned to return to Pakistan on Wednesday to continue talks with the Pakistan Peoples Party, according to PPP spokesman Farhatullah Babar, reported the AP.