Image copyright Reuters Image caption Nawaz Sharif and his family have denied any wrongdoing

Pakistan's Supreme Court has ruled there is insufficient evidence of corruption to remove Nawaz Sharif from the role of prime minister.

It instead ordered a further investigation into money transfers.

Questions arose over the business dealings of Mr Sharif's family when three of his children were linked to offshore accounts in the Panama Papers leaks in 2015.

Mr Sharif and his family have denied any wrongdoing.

They have dismissed the claims as politically motivated.

The case has made headlines in recent months amid predictions it could determine the future of PM Sharif.

About 1,500 police officers were deployed around the court in Islamabad. Protesters nearby urged Mr Sharif to step down with shouts of "Go Nawaz, Go Nawaz", Reuters reports.

Stocks rose following the highly anticipated decision on Thursday.

The Supreme Court agreed to investigate Mr Sharif's offshore wealth late last year after opposition leader Imran Khan threatened street protests.

The focus of the probe was on the funds used to purchase property in London using offshore companies.

Mr Sharif's daughter Maryam, tipped as a future political star, and his sons Hasan and Hussein are implicated in the allegations.

Image copyright Getty Images Image caption Maryam Sharif is said to be her father's closest adviser

Mr Sharif says the wealth was acquired legally. But his critics have suggested offshore companies were used to launder illegally-obtained wealth or avoid taxes.

The Supreme Court's five-member bench was split on Thursday, with two judges voting against the prime minister but three choosing instead to order a further probe.

Mr Sharif's party, the Pakistan Muslim League - Nawaz (PML-N), hailed the decision and his daughter Maryam tweeted: "Praise and glory be to Allah alone."

What happens next? - Analysis by the BBC's Secunder Kermani in Islamabad

Both the prime minister's supporters and his critics have been claiming today's decision as a victory.

The prime minister wasn't disqualified - and that was the big fear he and his party had. Similarly, he hasn't been asked to step aside whilst this new investigation takes place.

However, opponents of the prime minster point out that two out of the five judges did recommend Nawaz Sharif should be disqualified, and the other three all felt further investigation was needed.

The prime minister's team will hope that the complex nature of the investigation could see any recommendation it reaches kicked into the long grass. In the meantime, they may try and unveil new voter-friendly policies to take the sting out of this case.

At the same time Imran Khan's PTI party, which has led the corruption allegations, will hope to keep the case in the headlines ahead of elections due to take place next year.

Investigators will now focus on how the family members transferred money to Qatar.

PM Sharif and his daughter told the Supreme Court last November that their London property was bought through investments in companies owned by the Qatari ruling family. But the opposition in Pakistan has dismissed the claims as "fake".

The so-called Panama Papers - 11 million secret documents leaked from Panama-based law firm Mossack Fonseca - set out the offshore financial activities of political and business leaders and the wealthy elite around the world.

There are legitimate ways of using tax havens and offshore companies, although these entities are often used to hide the true owners of assets or avoid paying tax on the money.

'Don't celebrate yet' - Pakistan media warns of trouble to come

Analysts in Pakistan were quick to warn Mr Sharif not to be too triumphant over the verdict, noting that the forthcoming investigation may yet harm him politically.

Kashif Abbasi of ARY News said the ruling party has "nothing to be happy about" while Munizae Jahangir of Aaj news said "the issue won't be resolved" until the investigation was concluded.

Similarly, Faysal Aziz Khan, head of Bol Media Group, said that investigations of the kind ordered by the court are "formed to probe criminals". He concludes that Mr Sharif "is definitely in trouble."

Compiled by BBC Monitoring