The five judges reached a unanimous verdict in the Islamabad court, which was filled to capacity.

“Following the verdict, Nawaz Sharif has resigned from his responsibilities as prime minister,” a spokesman for Mr Sharif’s office said in a statement. However, it said he had “serious reservations” about the judicial process.

There was heightened security in the capital, with tens of thousands of troops and police deployed.

One of the judges, Ejaz Afzal Khan, said that Mr Sharif was no longer “eligible to be an honest member of the parliament”.

The court has recommended anti-corruption cases against several individuals, including Mr Sharif, his daughter Maryam and her husband Safdar, Finance Minister Ishaq Dar and others.

Opening the gates of power?

By M Ilyas Khan, BBC News, Islamabad

Pakistan has repeated history. Prime Minister Nawaz Sharif is resigning. He was the 18th prime minister of Pakistan. Not a single one of the 17 prime ministers that preceded him have completed their full term in office.

Many believe that the Supreme Court has started a process of cracking down on corruption, which augurs well for democracy. Others see this as part of a long history of political manipulation through which the country’s powerful military establishment has sought to control civilian decision-making.

The case hearings – spread over nearly 15 months – have been marred by controversy. The case belongs in a criminal court. The Supreme Court, which is an appellate body, initially refused to hear it. But then it not only admitted the petition for hearing, it also took the unusual step of instituting its own investigation into the case, with a dominant role for military intelligence services.

Many believe that while across-the-board action against corruption may remain a pipe dream, this verdict will open the gates of power for a new set of politicians – as has often happened in the past.

Mr Sharif, who was serving as prime minister for a record third time, was less than a year away from becoming the first in Pakistani history to complete a full term in office.

He served as prime minister from November 1990 to July 1993 and from February 1997 until he was toppled in a bloodless coup in October 1999.

Image copyrightReuters

Image caption
Opposition supporters erupted in applause as the verdict was announced

Allegations of corruption have dogged Mr Sharif since the 1980s. And much of what the Panama Papers revealed was the subject of a federal inquiry in the mid-1990s.

What happens next?

It is not immediately clear who will succeed Mr Sharif, but his brother Shehbaz, who is chief minister of Punjab province, is seen as a strong contender for the job.

Pakistan’s ruling party, the Pakistan Muslim League-Nawaz (PML-N), will be permitted by the speaker of the National Assembly to select an interim prime minister to rule until the 2018 general election.

The PML-N, which has the most seats in parliament, is expected to deliver a statement later on Friday.

Opposition parties will also have the opportunity to put forward their own candidates for the position.

Meanwhile, the court has directed the National Accountability Bureau (NAB), the main anti-corruption body, to compile and send four references to accountability courts against Mr Sharif and others.

The NAB has been directed to file these references within six weeks. The accountability courts have been directed to complete hearings in these cases in six months.

What did the Panama Papers reveal?

The leaks in April 2016 revealed that three of Mr Sharif’s children owned offshore companies and assets not shown on his family’s wealth statement.

The companies were allegedly used to channel funds to acquire foreign assets, including some apartments along Park Lane in London’s Mayfair area.

Despite documents from the Panama Papers suggesting that the beneficial owner of the luxury central London flats was Mr Sharif’s daughter Maryam, she later claimed that she was only a trustee – and that it was her brother who was the beneficial owner.

To prove her point, Maryam Nawaz produced a trust deed signed by both her and her brother dated February 2006.

What is the mood in Pakistan?

As the verdict was announced, opposition supporters erupted in applause, rushing into the street chanting slogans and handing out sweets, according to reports.

The vice-chairman of the Pakistan Tehrik-e-Insaf (PTI) party, Shah Mehmood Qureshi, called it an “historic day” and praised the Joint Investigation Team (JIT) for “not succumbing to the enormous pressure and serving the cause of justice.”

The verdict was announced amid heightened security in the capital, with about 3,000 armed police and members of the Pakistan Rangers paramilitary force deployed near and around the Supreme Court.

Image copyrightGetty Images

Image caption
There was a large security presence outside Pakistan’s Supreme Court ahead of the ruling

The ruling represents the peak of a drama that has fuelled news coverage and social media debates for months, attracting both scorn and ridicule as well as trenchant support for the prime minister.

The divisions fall largely along party lines but amid the febrile accusations, many have also expressed concerns over Pakistan’s political culture.

The Wikipedia profile of the prime minister has also been littered with obscenities and accusations.

Mr Sharif is not the first prime minister to lose his position following the leaking of documents from the Panamanian law firm.

Iceland’s prime minister was forced to resign after documents appeared to reveal that he and his wife concealed millions of dollars’ worth of investments in an offshore company.