A court in Islamabad has granted former Pakistani prime minister Imran Khan a two-week reprieve from arrest in a corruption case, granting him bail on the charges.

Babar Awan, the lawyer for Khan, said the court made the decision on Friday, a day after the country’s supreme court asked it to make a ruling.

He said Khan is now “a free man”, adding that the decision was just.

Imran Khan supporters
Supporters of Pakistan’s former Prime Minister Imran Khan (AP)

The ruling came after Khan returned to court to hear whether he will be shielded from renewed arrest or taken back into custody – a decision that put the government and legions of Khan supporters on edge after days of violent confrontations.

However, Khan did not immediately leave the courtroom after the initial decision as the judges proceeded to deliberate whether to grant him bail in several other corruption cases filed against him.

Under Pakistan’s legal system, a person granted bail would still have to face a trial.

A short while later, the court said Khan could not be arrested for the time being in other pending corruption cases against him.

The former premier is expected to walk out of the court shortly.

The government contends that Khan’s release rewards and encourages mob violence.

Pakistan army
A convey of army troops patrol at a road to ensure security after clashes between police and supporters of Khan (AP)

After he was arrested on Tuesday, his supporters attacked military installations, burned vehicles, and ambulances and looted general stores in various parts of the country.

The government responded with a crackdown, arresting nearly 3,000 people. The violence left at least 10 Khan supporters dead. Dozens of protesters and more than 200 police officers were injured.

The arrest on Tuesday was a startling and controversial move. Agents from the National Accountability Bureau burst into the Islamabad high court where Khan was attending a session on other charges — the same court where he appeared on Friday — and dragged him away, putting him into an armoured vehicle.

On Thursday, Pakistan’s supreme court ruled that arrest unlawful, but asked the Islamabad high court, a lower court, to reconsider its initial decision to uphold the arrest.

The controversy surrounding Khan – a figure who inspires both vehement loyalty and furious opposition – threatens to open a deeper vein of turmoil in a country that has seen multiple military takeovers and bouts of violence.

Imran Khan car
People chasing a car carrying Pakistan’s former PM Imran Khan to court (AP)

The unrest has echoed that which followed the 2007 assassination of former prime minister Benazir Bhutto during an election rally. Her supporters at the time, outraged by her killing, rampaged for days across Pakistan.

Khan, a former cricket star turned Islamist politician, was removed as prime minister last year by a no-confidence vote in parliament and now leads the opposition. He faces more than 100 legal cases, most involving allegations that he incited violence and threatened police and government officials.

He also faces at least three corruption cases, including accusations from the National Accountability Bureau that he accepted millions of dollars worth of property in exchange for providing benefits to a real estate tycoon.

A new terrorism charge was filed against him on Thursday for allegedly inciting his followers to violence after his arrest.

Following the supreme court’s release order on Thursday, Khan spent the night at a government guest house in Islamabad, where he met with family members and friends.

Pakistan’s president, Arif Alvi, also had a meeting with him. Mr Alvi has been trying to defuse tension between Khan and Prime Minister Shahbaz Sharif’s government to avoid an escalation.

Speaking at a special cabinet meeting on Friday to discuss the developments, Mr Sharif criticised the Supreme Court ruling, saying there was a “genuine corruption case” against Khan, “but the judiciary has become a stone wall protecting him”.

As Mr Sharif’s government contends with the political turmoil amid a worsening economic crisis, it is also dealing with militant attacks.

According to Pakistan’s military, two soldiers were killed and three were wounded on Friday when insurgents attacked a security post in the town of Muslim Bagh in southwestern Baluchistan province.

It said two insurgents were also killed in the exchange of fire.