Pakistan's top court has reinstated the country's chief justice in a move being seen as a serious blow to the authority of President Pervez Musharraf.
Judge Chaudhry is a staunch opponent of Gen Musharraf
Iftikhar Chaudhry was suspended by the president four months ago amid claims of corruption, but has since become a focus of opposition to Gen Musharraf.
Gen Musharraf, who seized power in 1999, is facing mounting criticism of his rule and a wave of bombings.
The government says it will respect the court's decision.
Critics of the president say the suspension was an attempt to undermine the judiciary's independence in an election year.
The Supreme Court judges ruled by 10 votes to three to quash all charges against Mr Chaudhry, calling his suspension "illegal".
Delivering the court's verdict, presiding Judge Khalil-ur-Rehman Ramday said: "The reference [against Mr Chaudhry] has been set aside and the chief justice has been reinstated."
Lawyers applauded the ruling as it was read out, and jubilant crowds outside the court shouted chants of "Go Musharraf, go".
Mr Chaudhry's lawyer, Aitzaz Ahsan, told reporters: "He has been restored and it is a victory for the entire nation."
Gen Musharraf had earlier said he would accept the court's decision and Prime Minister Shaukat Aziz issued a statement to this effect after the ruling.
Lawyers outside the court celebrate the reinstatement
"I would like to emphasise that we must all accept the verdict with grace and dignity, reflective of a mature nation.
"This is not the time to claim victory or defeat. The constitution and the law have prevailed and must prevail at all times," Mr Aziz said.
The government said the case had no political motive.
Officials alleged that several people had complained to the president that Mr Chaudhry had misused his office and received favours. In particular, he is alleged to have procured a top police job for his son.
But critics say the government has not shown similar zeal in pursuing more serious charges - such as financial embezzlement and property fraud - against other top judges.
They accuse the president of plotting to remove an independent-minded judge to forestall legal challenges to his plan to ask parliament for another five-year term in office.
Mr Chaudhry's suspension in March triggered mass protests.
He has become a highly controversial figure in recent months as he has toured the country.
Although he has not directly criticised Gen Musharraf, his campaign road show has definitely taken on the feel of a political campaign, the BBC's Dan Isaacs in Islamabad says.
The judicial crisis has been overshadowed by a recent siege of Islamabad's radical Red Mosque and a spate of bombings that have killed scores of people.
On Tuesday, 15 people were killed at a rally Mr Chaudhry had been due to attend in Islamabad. It remains unclear who carried out the bombing or who the intended target might have been.
On Friday, three civilians and one soldier were killed in a suicide attack in North Waziristan, a security official said.