ISLAMABAD/PESHAWAR, Pakistan — Pakistan's prime minister Nawaz Sharif was ousted by the country's top court Friday amid a corruption investigation into his family wealth triggered by a data dump known as the Panama Papers.

The third-term leader was ruled unfit for office by the Supreme Court in a unanimous decision by five judges.

Nawaz Sharif pictured in June. B.K. Bangash / AP

The court asked the president of the country — a nuclear power and important U.S. ally — to nominate a new prime minister and ordered a criminal investigation into Sharif and his family.

Information Minister Maryam Aurangzeb — a close Sharif aide — said the prime minister reluctantly accepted the ruling. An official later confirmed Sharif had resigned.

"Let me admit here that we lost our case in the court of law, though we are upset on this decision," Aurangzeb told a news conference in Islamabad.

His opponents took to the streets in celebration of Friday’s ruling, but there were reports that some supporters had set up roadblocks in the city of Lahore.

The case dates back to 2016, when documents leaked from a Panama-based law firm Mossack Fonseca indicated that Sharif's sons owned several offshore companies.

Opponents of Nawaz Sharif cheer Friday's ruling. Anjum Naveed / AP

Sharif's son, Hussain Nawaz, at the time acknowledged owning offshore companies but insisted they used legal money to set up businesses abroad.

Sharif served as prime minister twice in the 1990s, but was ousted by a military coup in 1999. That led to a decade of exile until he became the nuclear power's prime minister, again, in 2013.

Wajahat S. Khan reported from Islamabad, Mushtaq Yusufzai reported from Peshawar.