Pakistan's Supreme Court has declared the arrest of former Prime Minister Imran Khan earlier this week illegal and ordered law enforcement agencies to present Khan before a high court that is hearing a corruption case against him as violent protests by his supporters swept the country.

The court ruled Thursday Khan's arrest was unlawful because of the manner in which he was taken into custody. Khan on Tuesday had appeared for a hearing at the Islamabad High Court, where he was forcibly dragged out by paramilitary troops.

Former Pakistani Prime Minister Imran Khan (back) leaves after appearing in the Supreme Court in Islamabad, Pakistan, on May 11, 2023. (Anadolu Agency/Getty/Kyodo)

Chief Justice Umar Ata Bandial urged Khan on Thursday to appeal to his supporters to remain peaceful after crowds in Islamabad and other cities protested the arrest and clashed with military personnel, leaving several people dead.

Khan, a cricket star-turned-politician, has blamed the military for his ouster from office after a no-confidence vote in parliament in April 2022.

The former prime minister has been campaigning for early elections and been at odds with the military establishment, with several criminal cases initiated against him.