The legal case against Megaupload founder Kim Dotcom continues to spiral out of control as New Zealand's Prime Minister announced this week that an inquiry into unlawful government spying on Dotcom and others has been launched.

Prime Minister John Key announced on Monday that an inspector general has launched an investigation into allegations that a government intelligence service had illegally intercepted the communications of Dotcom and other individuals targeted in the case.

The wiretapping was allegedly done by the Government Communications Security Bureau, or GCSB, as part of a controversial January raid on the Dotcom mansion. The GCSB intercepted communications in an effort to help the New Zealand police locate individuals who were being sought for arrest in the Megaupload case, according to Key.

Dotcom and co-defendant Bram van Der Kolktheir, as well as their families, are all New Zealand residents and were reportedly targeted in the communications interceptions.

By law the GCSB is required to obtain warrants to intercept communications involving New Zealand citizens and residents, and to have the prime minister sign off on such warrants before conducting the surveillance. But Key said he was not asked to approve warrants in this case, nor was he briefed on the GCSB operation beforehand.

Key said he was “quite shocked” when he found out last week that the GCSB had committed the unlawful communications intercepts.

“I expect our intelligence agencies to operate always within the law," he said in a statement released by his office. "Their operations depend on public trust."

In an interview with Radio New Zealand (.mp3), Dotcom’s U.S. lawyer, Ira Rothken, said he and the Megaupload founder were “deeply concerned that there appears to be allegations of domestic spying on residents that bypasses the judicial process and the checks and balances on that.”

Rothken and Dotcom found out about the spying and inquiry only through a press release issued by Key's office.

“We look forward to this inquiry and appreciate the Prime Minister doing the right thing,” Rothken said in the interview.

The GCSB, which proclaims on its website that it has “Mastery of Cyberspace for the security of New Zealand," is in charge of conducting foreign telecommunications and internet intelligence, as well as ensuring the integrity and confidentiality of government communications.

Dotcom and the Megaupload case has become a cause célèbre in New Zealand after his mansion was raided by 70 heavily armed police officers who arrived via helicopters.

The Megaupload founder and his three co-defendants, van der Kolk, Mathias Ortmann and Finn Batato, are currently out on bail in New Zealand, awaiting a hearing next March to determine if they should be extradited to the U.S. to face charges of secondary copyright infringement for operating file-sharing websites.

If found guilty, the four could face up to 20 years in prison and million-dollar fines.

But so far, Dotcom has scored multiple legal victories in the campaign to defend himself against what the U.S. calls the biggest copyright infringement case in history.

A court has already ruled that warrants used to conduct the raid on his residence were unlawful. And a New Zealand judge also declared that the FBI acted illegally when it cloned the data on computer hard disks seized from Dotcom's residence in the raid and sent them to the U.S.

Via Twitter, Dotcom expressed surprise that a government intelligence agency was involved in his copyright case and said that he welcomed the government inquiry into the spying, but that he thought the inquiry into wrongdoing should be extended to his entire case.