Policemen escort Pakistan's former prime minister Imran Khan (C) as he arrives at the high court in Islamabad on May 12

Islamabad (AFP) - Former Pakistan prime minister Imran Khan was granted bail by the Islamabad High Court on Friday, after his arrest on corruption charges this week sparked deadly clashes before being declared illegal.

The high court also ruled that Khan could not be arrested before Monday in any other case registered against him.

Several thousand of his supporters have rampaged through cities across the country in protest at Khan’s detention since Tuesday, setting fire to buildings, blocking roads and clashing with police outside military installations.

“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, where he remained late Friday hours after his hearings ended.

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

Police used tear gas to hold back protestors who gathered a few kilometres away from the court, which was heavily guarded, with gun shots fired at officers after dark, Islamabad police tweeted without giving further details.

Khan has become tangled in a slew of legal allegations – a frequent hazard for opposition figures in Pakistan – since he was ousted from power in April last year.

He had launched an unprecedented campaign of defiance against the military, which independent analysts say helped him rise and fall from power.

General elections are due no later than October, and the former cricket star has accused the shaky incumbent coalition government of supplanting him in cahoots with top generals.

The 70-year-old has also made explosive claims that they puppeteered a November assassination attempt which saw him shot in the leg as he campaigned for snap polls.

Khan was manhandled into custody by paramilitary troops at the Islamabad High Court on Tuesday, but the Supreme Court later declared the arrest unlawful and demanded the process be “backtracked”.

He returned to Islamabad High Court on Friday where he was granted two weeks interim bail in the graft case as well as in all other cases against him until at least Monday, lawyers for Khan said.

“Khan, your devotees are countless,” lawyers for his party gathered in front of the court chanted as the ousted leader raised a fist above his head.

The interior minister has vowed to re-arrest Khan, who remains wildly popular.

- Labyrinthine legal cases -

At least nine people died in the unrest triggered by his arrest, police and hospitals said.

Hundreds of police officers were injured and more than 4,000 people detained, mostly in Punjab and Khyber Pakhtunkhwa provinces, according to authorities.

On Thursday, Chief Justice Umar Ata Bandial said Khan’s arrest was unlawful because it took place on court premises where Khan had intended to file a bail application.

“Your arrest was invalid, so the whole process needs to be backtracked,” he said.

Khan remained in the bench’s custody under police protection for his own safety until he arrived on Friday at the Islamabad High Court, where hundreds of security forces were deployed and nearby roads shut.

- ‘Country needs peace’ -

Islamabad police had issued an emergency order banning all gatherings in the capital city after Khan’s Tehreek-e-Insaf (PTI) party called for supporters to come together.

Faisal Hussain Chaudhry, a lawyer for Khan, told reporters that further arrests of senior PTI leaders had brought the total number to 10.

“The country needs peace but such steps by the government are not helpful,” he said.

Despite the ruling on the legality of Khan’s arrest, Interior Minister Rana Sanaullah refused on Thursday to back down.

“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.

Khan’s arrest came after the army rebuked him for once again repeating allegations they were involved in his assassination attempt.

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 influence over domestic politics and foreign policy and has staged at least three coups and ruled for more than three decades.