The three-member bench of the court declared Khan’s arrest unlawful, providing a major relief for the chairman of the Tehreek-e-Insaf party.
The bench had heard the petition over the legality of Khan’s arrest earlier in the day and ordered authorities to bring him to court within an hour.
Khan’s shock arrest has triggered violent protests across the country, prompting the government to call out the army to help restore order.