Imran Khan leaves court after being granted bail

Watch: Imran Khan's arrest saga... in under 90 seconds

Pakistan's ex-prime minister Imran Khan has left court premises in Islamabad, a day after the Supreme Court ruled his dramatic arrest on corruption charges was illegal.

On Friday evening, Mr Khan's party said he was heading for the city of Lahore.

Judges granted Mr Khan protected bail, meaning he can not be re-arrested on those charges for two weeks.

The court also ordered he could not be arrested on any charges filed after last Tuesday until 17 May.

Despite the rulings, the corruption charges against Mr Khan still stand.

"The head of the country's largest party was abducted, kidnapped from the high court, and in front of the entire nation," Khan told AFP from the court building.

"They treated me like a terrorist, this had to have a reaction," he said of the protests that followed.

Mr Khan remained within court premises after the hearing on Friday seeking preventive bail against other charges, which he told the BBC included counts of terrorism, sedition and blasphemy.

Conviction would disqualify the former international cricket star - and Pakistan's prime minister from 2018 to 2022 - from standing for office, possibly for life. Elections are due later this year.

Mr Khan had arrived at the hearing under heavy armed guard, and greeted supporters with a single raised fist.

Speaking during Friday's hearing, Chief Justice Umar Ata Bandial said the arrest was unlawful because it took place on court premises.

He ordered that the "whole process" of Mr Khan's arrest "needs to be backtracked".

The 70-year-old - who was arrested on Tuesday as he arrived at a courthouse in Islamabad - pleaded not guilty to the charges when a judge formally indicted him with corruption for the first time in the dozens of cases he faces.

Officials say Mr Khan unlawfully sold state gifts during his premiership, in a case brought by Pakistan's Election Commission.

AFP Imran Khan leaving court on Friday. He is wearing sunglasses and making his way through a crowd of people.AFP
Imran Khan was surrounded by a crowd of people as he left court on Friday

The dramatic saga has significantly escalated tensions between Mr Khan and Pakistan's powerful military.

Many analysts believe Mr Khan's election win in 2018 happened with the help of the military, which both parties denied.

But he later fell out with the army. After a series of defections, and amid mounting economic crises, he lost his majority in parliament.

Since being ousted less than four years into his term, he has become one of the military's most vocal critics, and analysts say the army's popularity has fallen.

And his PTI party says the charges against him - which relate to gifts given to him by foreign leaders while he served as prime minster - are politically motivated.

Watch Tuesday's dramatic arrest of Pakistan's former prime minister

His dramatic arrest outside the courthouse on Tuesday sparked outrage among Mr Khan's supporters.

At least 10 people were killed and some 2,000 arrested as unrest swept the country. Those protests included an attack at a military commander's home residence in Lahore, which was set on fire.

While this week's violence petered out after the army was deployed in Islamabad and other areas, such as Punjab and Khyber Pakhtunkhwa, the country remains on edge.

Critics say the PTI has been fuelling unrest through social media posts calling for protesters to take to the streets, and judges told Mr Khan that he must condemn the violence and tell supporters to stop.

Mr Khan says he and his party only call for peaceful protest.

Pakistan's current Prime Minister Shehbaz Sharif, who took power after Khan was ousted, criticised the Supreme Court's ruling to free Khan in a cabinet speech aired on state TV.

He alleged that judges had favoured Imran Khan, and their ruling had caused "the death of justice in Pakistan".

He further criticised Mr Khan and his party for their inflammatory language and encouraging protesters to take to the streets.

"Imran Khan has divided the nation," he said.

Additional reporting by Frances Mao.