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, dismissing the claims as politically motivated.
About 1500 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 has reported.
Stocks rose after the decision was handed down.
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 were implicated in the allegations.
Mr Sharif said 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, hailed the decision and his daughter Maryam tweeted: "Praise and glory be to Allah alone."
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 might 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 concluded that Mr Sharif "is definitely in trouble."