Pakistani Prime Minister Nawaz Sharif was ousted from power Friday by the country’s Supreme Court after months of hearings on corruption charges against Sharif and his family. The historic ruling, while hailed by Sharif’s opponents as a victory for Pakistani democracy, threw the country’s political future into turmoil.

The embattled three-time premier, 67, immediately accepted the dismissal, quashing concerns about a possible military intervention in the nuclear-armed, Muslim-majority country of 180 million. No Pakistani prime minister has ever finished his or her term since the country’s founding in 1947, and Sharif was overthrown by the army in 1999 during his second term.

There were unconfirmed reports in the Pakistani media that the Parliament, dominated by the ruling Pakistan Muslim League-N, was likely to swiftly name Sharif’s younger brother Shahbaz Sharif, the elected leader of Pakistan’s Punjab Province, to replace him until elections scheduled for next summer.

[Pakistan’s prime minister, having survived Supreme Court corruption ruling, now faces pressure]

But the stunning, unanimous verdict by five members of a high-court panel, whose senior justice excoriated Nawaz Sharif and his family for engaging in “mafia”-like financial dealings, gave a powerful boost to Pakistan’s major opposition leader, former cricket star Imran Khan, 64, who brought the case against Sharif in the Supreme Court more than a year ago.

A supporter of Nawaz Sharif passes out after the Supreme Court's decision to disqualify Sharif from the prime ministership in Lahore, Pakistan, July 28, 2017. (Mohsin Raza/Reuters)

The capital was tense and expectant Friday as the nation awaited the verdict. Riot police and paramilitary officers surrounded the Supreme Court building, and the military was on high alert. The courtroom was packed as the ruling was announced, with numerous opposition leaders in the room.

The ruling reinforced the court’s previous findings that the prime minister had lied about his family’s wealth and business transactions. It referred the case to a special “accountability” court for prosecution of Sharif and three of his children. In April, the court voted 3 to 2 against ousting him but commissioned a special investigation into the matter.

The case stemmed from the “Panama Papers” scandal of 2016, in which leaked documents from a Panamanian law firm implicated leaders of several foreign countries, including Pakistan, in shady financial dealings. Khan and others brought these allegations to court, charging that the Sharifs had hidden their wealth overseas through a complex trail of real estate transactions.

Sharif repeatedly denied the charges in court and speeches to the nation, but he offered varying and sometimes contradictory explanations as to how he and his family had financed various properties, especially a group of luxury apartments in London. In one melodramatic twist, a prince from Qatar declared that he had purchased the property and given it to the family.

[Pakistan, accused of terrorist infiltration, starts to fence its border with Afghanistan]

Aides to Sharif said Friday that he was leaving office immediately in compliance with the ruling but that he had “deep reservations” about it. Information Minister Marriyum Aurangzeb told reporters that “not a single paisa [the smallest currency denomination] of government corruption has been established by this verdict.”

“Nawaz Sharif lives in the heart of the masses. He does not need a ruling chair,” she said. Sharif’s daughter Maryam Sharif, whose role in the London real estate matter was central to the case, tweeted that her father’s party “stands united, more resolute and unfazed.”

But supporters of Khan, a charismatic grass-roots leader who is likely to seek the premiership, held boisterous celebrations outside his home in the Islamabad suburbs and elsewhere, dancing and chanting and distributing sweets. Khan has led mass rallies against Nawaz Sharif for several years, denouncing him as part of a corrupt political elite.

At a news conference, Khan hailed the ruling as “the beginning of a new era in the history of Pakistan” in which there would no longer be “two types of laws, one for the weak and one for the wealthy and powerful. . . . In this new era, justice will reign supreme. It is the victory of the entire nation.” Khan said that he bore no grudge against Sharif but that he and all political leaders “should be held accountable.”

After months of hearings in the case, a Supreme Court panel in April ruled 3 to 2 against disqualifying Sharif from office. But it ordered a special investigation into the family’s convoluted financial transactions and raised numerous questions, often in sharp and skeptical language, about where “huge sums” had come from to pay for various properties with no paper trail.

Experts in Pakistan and the United States said the court ruling and ouster of Sharif was a mixed blessing for the country, which has struggled to develop as a democracy while the powerful military establishment has ruled from the wings and repeatedly intervened in politics.

“This is a blow to the democratic process but a victory for democratic principles,” said Michael Kugelman, a regional expert at the Woodrow Wilson International Center for Scholars in Washington. “Once again a democratically elected prime minister will not serve out a full term, and the political system has suffered a shock, but it will survive. We’ve come a long way since the days of military rule.”

[Pakistan pivots to China amid fresh concerns over U.S. ties with India]

In the past, Pakistan’s military establishment has been wary of Sharif, in part because of his early diplomatic overtures to archrival India and in part because he sought to increase civilian control over the military. But the premier backed off of those efforts later in his term, while a spate of horrific terrorist attacks has brought the country’s military and civilian leadership closer together in opposing Islamist extremism.

Some aides to Sharif, however, have depicted the high court’s aggressive intervention as a “soft coup” against Sharif and his party. They have suggested that Khan colluded with the military in seeking to bring him down politically, which the opposition leader has denied.

“I don’t see any immediate instability flowing from this situation, but Pakistan is destined to be politically uncertain until the next election,” said Moeed Yusuf, a Pakistan expert at the U.S. Institute for Peace who is visiting Pakistan. “In the short run, it will make the military stronger in dealing with the U.S. and foreign powers, since they will not be sure whom to talk to on the civilian side.”

Hussain reported from Islamabad.

Read more:

29 arrests ordered in ‘revenge rape’ of Pakistani girl, police say

In Pakistan, scorching Ramadan month highlights chronic water, power shortages

A much-feared Taliban offshoot returns from the dead

Today’s coverage from Post correspondents around the world

Like Washington Post World on Facebook and stay updated on foreign news