Pakistan's Supreme Court has reinstated Iftikhar Muhammad Chaudhry as the country's chief justice, four months after he was suspended by Pervez Musharraf, the Pakistani president.
Chaudhry became a symbol of resistance to General Musharraf after refusing to quit in the face of pressure from the president and his intelligence chiefs.
Justice Khalil-ur-Rehman Ramday, head of the 13-member court, said: "The reference has been set aside and the chief justice has been reinstated."
The verdict on Friday is seen as a blow to Musharraf and possibly the biggest challenge to his dominance since he seized power in a coup in 1999.
It could further complicate his bid to win a new five-year presidential term this fall.
The chief justice was suspended on March 9 following allegations that he abused his position, including using influence to get his son a job, fiddling petrol expenses and that he had a penchant for expensive cars.
The government filed a statement in the Supreme Court last month in which it also accused Chaudhry of harassing judges, showing bias in appointments and intimidating police and civil servants.
On Friday the court wrapped up the 43-day hearing of an appeal by Chaudhry against his March 9 ouster.
The announcement sparked celebrations by lawyers who had spent the day waiting outside the court for the verdict.
Retired Major General Rashid Qureshi, General Musharraf's spokesman, said the court ruling reinstating Chaudhry would be honoured and respected.
"The president has said the judgement of the Supreme Court will be honoured, respected, and adhered to," he said.
Shaukat Aziz, Pakistan's prime minister, said the government accepted the decision but that it was "not the time to claim victory or defeat".
Ramday, speaking before the ruling, said the court would not be swayed by the political sensitivities of the case and stressed its objectivity despite massive protests by pro-Chaudhry lawyers against Musharraf.
"The judiciary is here not as rivals, monitors or superiors to any institution," he said.
Musharraf's action against the judge sparked mass pro-democracy protests and political violence in Karachi that left more than 40 dead.
Chaudhry's supporters say the president ousted the judge because he could have kept Musharraf from maintaining his grip on power and because he took on cases about people allegedly abducted by Pakistan's intelligence agencies.
Musharraf, the president and army chief, hopes to get himself re-elected in uniform by the outgoing parliament this year, defying the constitution which says he should quit as head of the military by the end of 2007.
General elections are due no later than early next year.