ISLAMABAD -- 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 had 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 against Khan are "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, a charge the government denies.

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.

In an apparent retaliation by Khan's camp, police in the most populous province of Punjab -- where Khan's allies run the provincial government -- filed terrorism charges Thursday against Rana Sanaullah, the interior minister in Sharif's government. The charges stem from a citizen's accusation that the minister had threatened judges there last year.

In Pakistan, terrorism charges can be levied against anyone accused of threatening a government official or Pakistan's military and security institutions.

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."

In a boost for Sharif's government, Saudi Arabia pledged Thursday to invest US$1 billion in Pakistan. The pledge came during a telephone between the foreign ministers of the two nations, the state-run Saudi Press Agency reported.

The report offered no details on whether the money would be assistance for projects or a deposit in Pakistan's reserves to help Islamabad weather the economic crisis it now faces. On Wednesday, Qatari Investment Authority said it was prepared to invest $3 billion in Pakistan. Saudi Arabia is a major benefactor for Pakistan and many Pakistanis work in the kingdom.

------

Associated Press writer Jon Gambrell in Dubai, United Arab Emirates, contributed to this report.