Islamabad, Pakistan - Pakistan's Supreme Court has ruled that there was insufficient evidence to oust Prime Minister Nawaz Sharif over corruption allegations, but has ordered a high-level investigation into the charges.

The court issued its verdict on Thursday afternoon after months of hearings in a case based on the "Panama Papers" leaks that was moved by opposition leaders seeking Sharif's removal from office.

Following the announcement, both Sharif's ruling PML-N and opposition leader Imran Khan's PTI party claimed the verdict as a "victory".

"The Supreme Court has decided … the same thing that Nawaz Sharif himself had decided six months ago, when he ordered the formation of a commission to investigate [the allegations]," Khawaja Asif, a senior PML-N leader, told reporters outside the court following the announcement.

Speaking to the press after the verdict, Khan termed the decision "historic" and called for Sharif to step down pending the completion of the investigation in 60 days from its formation.

"The [order for an investigation] means that whatever explanation [PM Sharif] had given in the Supreme Court regarding the source of income and the money trail has been rejected," said Khan.

"I demand that [Sharif] should resign immediately. And if you are cleared in 60 days, you should return."

The five-member bench, which was split 3-2 on the judgment, decided that the source of the funds and assets in question had still not been conclusively established by Sharif.

It ordered Sharif and his children Hassan, Hussain and Maryam to submit themselves for investigation to a joint investigation team comprising members of the Federal Investigative Agency, intelligence agencies, the central bank and other bodies.

The body will be constituted within seven days, and submit fortnightly reports to the Supreme Court, the verdict said. It will complete its investigation in 60 days, it said.

In a dissenting note in the verdict, which is not binding, two judges on the bench declared that Sharif should stand disqualified for having lied about his sources of income.

Corruption allegations

The allegations focus on Sharif's previous two terms in office in the 1990s, with opposition politician Imran Khan and others alleging that the prime minister and his family illegally profited from his position.

Security was tight around the capital Islamabad on Thursday morning, with dozens of police officers deputed to secure the government quarter where the Supreme Court is located.

In 2016, the International Consortium of Investigative Journalists leaked 11.5 million documents from law firm Mossack Fonseca. Included in those documents were letters showing that three of Sharif's children - Maryam, Hassan and Hussain - were listed as beneficiaries for three companies registered in the British Virgin Islands.

The documents showed these companies were involved in a 2007 loan of $13.8m, made using high-value Sharif-owned properties in the United Kingdom as collateral, and a separate 2007 transaction amounting to $11.2m.

Owning off-shore companies is not illegal in Pakistan, but Sharif's political opponents allege this $25m was gained through corruption during his previous two terms in office as prime minister in the 1990s.

Sharif contends that the money is in his children's names and he was therefore not obliged to declare the assets on tax and other disclosure documents. Moreover, he claims it was raised through legitimate business deals, mostly based in the Gulf countries.

The Supreme Court took up the case last year after months of wrangling between the government and opposition over the formation of a commission to probe the allegations.

Asad Hashim is Al Jazeera's Web Correspondent in Pakistan. He tweets @AsadHashim