Pakistan's Supreme Court disqualified Prime Minister Nawaz Sharif on July 28, ordering his removal from office in connection with corruption charges stemming from the Panama Papers leak in 2016.
Sharif resigned shortly after the court order was issued amid tight security in the capital, Islamabad.
The ruling ordering Sharif out immediately came after an investigative panel alleged that Sharif's family could not account for what it said was vast wealth in offshore companies.
"He is no longer eligible to be an honest member of the parliament, and he ceases to be holding the office of prime minister," Ejaz Afzal Khan, one of the judges, said in court.
In a brief statement, Sharif's office said Sharif "relinquished his charge" as prime minister after learning of the Supreme Court's decision.
The statement suggested that the decision was unjust and said Sharif had "serious reservations about the judicial process," but that he stepped down to show his respect for the judiciary and rule of law.
Pakistani media reported that a criminal investigation would also be launched against Sharif, whowas serving as prime minister for the third time, and his family.
He has repeatedly denied any wrongdoing in the case while calling the inquiry into his family’s finances a conspiracy.
In an unexpected decision, the court also dismissed Finance Minister Ishaq Dar, an ally of Sharif who has been credited with helping Pakistan's economy reach its fastest pace of growth in a decade.
But Sharif's ruling Pakistan Muslim League-Nawaz (PML-N) party, which has a majority in parliament, is expected to name a new prime minister to hold office until elections due next year.
Crowds were assembled outside the Supreme Court in Islamabad, where more than 3,000 security personnel were deployed ahead of the ruling.
Sharif is among the major political casualties of the Panama Papers leaks that brought offshore finance under the spotlight.
Documents from the Panama-based Mossack Fonseca law firm that were made public in April 2016 revealed that three of Sharif’s four children owned offshore companies and assets not shown on his family's wealth statement.
Sharif's son Hussain Nawaz at the time acknowledged owning offshore companies but insisted they used legal money to set up businesses abroad.
In 2016, Iceland’s Prime Minister, Sigmundur Davíð Gunnlaugsson, stepped down amid public outrage that his family had sheltered money offshore.
One of Sharif's two previous stints as prime minister was cut short by a military coup in 1999.
He returned from exile to win a convincing victory in parliamentary elections in 2013.
With reporting by dpa, Reuters, AP the BBC and Tthe New York Times