This is an archived article and the information in the article may be outdated. Please look at the time stamp on the story to see when it was last updated.

ISLAMABAD (AP) — A Pakistani court on Thursday extended former Prime Minister Imran Khan’s protection from arrest through the end of the month, officials said, after police filed terrorism charges against the country’s popular opposition leader.

The decision effectively shields Khan from arrest until Sept. 1 over accusations that during a speech last weekend, he threatened police officers and a female judge — remarks that triggered the terrorism charges.

The decision also temporarily alleviates concerns of violent clashes between police and supporters of the former premier. Khan has been leading mass rallies and seeking early elections since he was ousted in April in a no-confidence vote in Parliament. The government says elections will be held as scheduled next year.

Outside the anti-terrorism court on Thursday, Khan told reporters that he had never threatened anyone. He also said the terrorism charges against him were politically motivated and that Prime Minister Shahbaz Sharif’s government fears Khan’s growing popularity.

“You are making fun of Pakistan,” Khan said of Sharif’s government.

Khan’s lawyer Babar Awan said the terrorism charges filed against Khan were “an act of revenge.”

Arriving at court, Khan’s vehicle was stopped at the gates and he was asked to walk into the compound, as ordinary suspects do, rather than drive up to the building as VIPs do.

Hundreds of Khan’s supporters gathered outside the court building, chanting slogans against Sharif’s government and claiming that Khan is being politically victimized.

Sharif replaced Khan after the April no-confidence vote. Legal experts say Khan could face from several months to 14 years in prison, the equivalent of a life sentence if he is found guilty. It is unclear when the trial on terrorism charges will start.

Khan faces two other cases against him.

Later on Thursday, he appeared briefly before another court where a criminal case was registered against him this week on charges of defying a ban on staging rallies in the capital, Islamabad. He is protected from arrest in that case as well, until Sept. 7.

Khan is also to appear before the Islamabad High Court on Aug. 31 to face contempt proceedings on charges of threatening a judge — the third case against him. Under Pakistani law, if convicted on that charge, he will be disqualified from politics for life. No convicted person can run for office.

It is the second time that Khan — a former cricket star turned Islamist politician — faces contempt charges. After elections in 1993, he was summoned but pardoned by the Supreme Court after describing the conduct of the judiciary as “shameful” and saying it did not ensure free and fair elections.

Legal experts say Khan has limited options and could avoid a conviction if he apologizes for his remarks against Judge Zeba Chaudhry. During the rally he addressed the judge, saying, “get ready for it, we will also take action against you.”

Khan’s anger at Chaudhry was apparently caused by her decision to allow police to interrogate Shahbaz Gill, a close Khan aide and the chief of staff for his political party, Tehreek-e-Insaf. Gill, arrested earlier this month for allegedly attempting to incite soldiers to revolt against top military leadership, remains in detention, pending trial.

Since his ouster, Khan has alleged — without providing evidence — that Pakistan’s powerful military took part in a U.S. plot to oust him. Washington, the Pakistani military and the government of Khan’s successor, Shahbaz Sharif, have all denied the allegation.

Khan came to power promising to break the pattern of family rule in Pakistan. His opponents contend he was elected with help from the powerful military, which has ruled the country for half of its 75-year history. Khan has vowed to oust Sharif’s government through “pressure from the people.”