Security personnel stand guard outside the Attock prison, where former Pakistan prime minister Imran Khan is being held
Security personnel stand guard outside the Attock prison, where former Pakistan prime minister Imran Khan is being held AFP

A Pakistan court on Wednesday ordered that former prime minister Imran Khan be kept in jail over allegations he leaked classified documents, a day after a judge granted his release in a separate graft case.

Since being ousted from power last year, Khan -- Pakistan's most popular politician -- has been tangled in a slew of legal cases he says are designed to stop him from contesting upcoming elections.

Following a brief hearing inside the jail on Wednesday, Khan's lawyer Salman Safdar told AFP his detention was extended for two weeks under the colonial-era Official Secrets Act.

Khan's three-year prison term for graft was suspended on Tuesday, but authorities kept him in custody at Attock prison, around 60 kilometres (37 miles) west of Islamabad, over the leaked documents case.

The case relates to a cable that Khan had touted as proof that he was ousted as part of a US conspiracy backed by the establishment, according to a report by the government's Federal Investigation Agency.

The United States and the Pakistan military have denied the claim.

Safdar said the legislation was generally used to prosecute military cases, and the decision to try Khan in a closed courtroom was "condemnable and concerning".

"It is a brazen and blatant violation of the fundamental rights," he said. "He has not been given a right to free trial."

The vice chairman of Khan's Pakistan Tehreek-e-Insaf (PTI) party, Shah Mahmood Qureshi, a former foreign minister, has also been arrested over the case.

Khan's lawyers allege he was arrested in the case two weeks ago, without his or their knowledge, allowing authorities to keep him behind bars after his graft sentence was lifted.

"This constitutes a manipulation of justice," Muhammad Shoaib Shaheen, another of Khan's lawyers, said Tuesday.

Khan's three-year sentence was handed down early in August by a judge who found him guilty of failing to properly declare gifts he received while in office.

The election commission subsequently banned him for five years from contesting elections.

The court on Tuesday said the sentence was short enough to be set aside, after Khan's team argued there were "serious jurisdictional defects" in the conviction made in "undue haste" without allowing them to present witnesses.

An appeal against the conviction is pending.

A former international cricket star, Khan has been embroiled in more than 200 cases that he argues are politically motivated.

Khan was also briefly detained on graft charges in May, sparking days of civil unrest, but since then PTI has been targeted by a major crackdown that has vastly diminished his street power and seen most of his senior leadership jump ship or be locked away.

While Khan was imprisoned this month, Pakistan's parliament was dissolved at the request of his successor Shehbaz Sharif to pave the way for a caretaker government that will usher in elections.

No date for the polls has been announced.