Pakistan's former prime minister Imran Khan was granted two weeks' bail on Friday after the Supreme Court ruled that his arrest by the military earlier in the week was unlawful.
Mr Khan, whose arrest on Tuesday triggered violent protests across the country by his supporters, appeared in Islamabad's High Court on Friday surrounded by heavy security.
The court was heavily guarded with armed paramilitary troops and police as Mr Khan was brought in a motorcade of nearly a dozen vehicles, according to the broadcaster Geo TV.
Television footage showed Mr Khan walking into the court surrounded by lawyers and security personnel.
Geo said supporters of Mr Khan clashed with the police elsewhere in the city, as they cleared roads for his convoy.
His detention by the military on Tuesday sparked unrest in the nation and was ruled “invalid and unlawful” by the Supreme Court on Thursday.
His party, Pakistan Tehreek-e-Insaaf (PTI) said thousands of “peaceful Pakistanis” from across the country would gather in Islamabad on Friday in solidarity with their leader.
Mr Khan, a cricket hero turned politician, was scheduled to appear before the Islamabad High Court at 11am for a hearing on his petition challenging the anti-corruption action against him. However, the hearing was delayed for nearly two hours because officials were conducting a security sweep of the courtroom, Pakistani media said.
Mr Khan's arrest escalated tensions between the public and military and aggravated instability in the country of 220 million people at a time of severe economic crisis, with record high inflation, anaemic growth and a delayed IMF funding.
His opponents say he was brought to power through a rigged election in 2018 by the generals, but he blames the military for his ousting from office in April last year in a parliamentary no-confidence vote.
The army, Pakistan's most powerful institution having ruled the country directly for almost half its 75-year history through three coups, denied Mr Khan's allegations.