Khan's party's deputy leader, former Foreign Minister Shah Mahmood Qureshi, was also granted bail.
The former prime minister was sentenced in the summer to three years in prison over graft charges. The sentence was suspended, but he remained in jail since August due to other charges against him, including the official Secrets Act case.
"The case has completely collapsed, and Imran Khan and Shah Mahmood Qureshi have finally been granted bail," lawyer Salman Safdar told reporters outside court.
Will Imran Khan be released from prison?
It is not yet clear whether Friday's bail decision would allow Khan to leave detention. Salman Safdar, one of his lawyers, told the Reuters news agency it the former prime minister has multiple arrest warrants issued against him in several other cases.
Khan denies the accusation. He says the cable's contents appeared in the media from other sources.
The former prime minister had argued that the diplomatic message was proof that the United States was conspiring with the Pakistani military to oust him in the 2022 no-confidence vote over his growing ties with Russia.