Pakistan ex-PM Imran Khan arrives at court for bail hearing
"Your arrest was invalid, so the whole process needs to be backtracked," Chief Justice Umar Ata Bandial told Khan at a hearing in the capital Islamabad on Thursday.
Khan was ordered to remain in the bench's custody under police protection for his own safety until Friday's court appearance.
The government has vowed to re-arrest Khan should he be denied bail, setting the stage for more unrest.
He arrived in a high-security convoy at Islamabad High Court before walking into the building flanked by dozens of police and paramilitary troops.
PTI lawyers gathered in front of the court shouted "Khan your devotees are countless" and "the lawyers are alive", to which the ousted leader raised a single fist above his head.
The area surrounding the court is on lockdown, with hundreds of security forces deployed.
Since being ousted from office last April, Khan has waged a tempestuous campaign for snap elections and fired unprecedented criticism at Pakistan's government and powerful military, whom he blames for pulling him from power.
He has accused senior military and government officials of plotting a November assassination attempt that saw him shot in the leg during a rally.
Khan has become tangled in a slew of legal cases -- a frequent hazard for opposition figures in Pakistan, where rights groups say courts are used to quash dissent.
The onetime cricket star was arrested on Tuesday at the Islamabad High Court on the orders of the country's top graft agency.
But on Thursday, the Supreme Court said the arrest was unlawful because it took place on court premises where Khan had intended to file a bail application.
Khan, 70, was ordered back to the same police headquarters where he has been sequestered since his arrest on the condition it should be treated as a "residence".
Imran Khan in Islamabad High Court. pic.twitter.com/zMtKblOS9Q— Anwar Lodhi (@AnwarLodhi) May 12, 2023
Islamabad Police issued an emergency order banning all gatherings in the capital city after PTI called for supporters to come together.
"We are hopeful that bail will be granted by the High Court," Faisal Hussain Chaudhry, a lawyer for Khan, told reporters.
He said further arrests of senior PTI leaders overnight -- bringing the total number to 10 -- showed the government was "not serious about solving the issue".
"The country needs peace but such steps by the government are not helpful," he said.
Despite the Supreme Court's ruling on the legality of Khan's arrest, Interior Minister Rana Sanaullah refused to back down on Thursday.
"If (Khan) gets bail from the High Court tomorrow, we will wait for the cancellation of bail and arrest him again," Sanaullah told Dunya TV.
With dozens of cases against him, Khan "has a long way to go", analyst Imtiaz Gul told AFP.
"This is just a timely relief, probably as part of efforts to de-escalate the explosive situation and reduce tensions," he said.
"The cobweb of criminal cases seems meant to entangle and thus incapacitate him from active politics" ahead of elections due in October, he said.
Several thousand of Khan's supporters had rampaged through cities around the country earlier this week in protest at his arrest, setting fire to buildings and blocking roads.
At least nine people died in the unrest, police and hospitals said.
Hundreds of police officers were injured and more than 3,500 people arrested, mostly in Punjab and Khyber Pakhtunkhwa provinces, according to authorities.
Khan has remained wildly popular since being ousted in April 2022 in a no-confidence vote in parliament after he lost the support of Pakistan's powerful military.
He now alleges the army is colluding with the government to keep him out of power.
Pakistani politicians have frequently been arrested and jailed since the country's founding in 1947.
But few have so directly challenged a military that holds significant influence over domestic politics and foreign policy and has staged at least three coups and ruled for more than three decades.