David Walters saw a business opportunity where few other foreign investors would dare to tread: Pakistan's power sector. He forecast profit by importing power stations, linking them to the national grid and selling the electricity to the energy-starved country.

But the former governor of Oklahoma didn't reckon on three things that would sour his multimillion dollar investments: the inability of the government to provide the fuel, a chronically unstable grid and, in the end, the country's activist Supreme Court.

Acting on a petition by lawmakers who alleged the businesses were little more than a scam, the court declared his company's plants and all other similar projects established in the country since 2006 illegal. Judges ordered criminal investigations into those involved, saying corruption marred the bidding process and the country didn't need any more power plants — just better management of existing ones.

Supporters say the decision was a much needed move by the only institution in Pakistan willing or able to strike a blow against rampant government graft and incompetence. Others called it a political decision by an overreaching court that has killed off any hope of foreign investment.

"Every company that will consider making an investment in Pakistan will now have a lump in their throat," said Walters, who counts his own losses in the millions and is vowing to seek international arbitration.

The chaos has highlighted the chronic mismanagement of Pakistan's power sector, which is unable to produce enough electricity to meet demand. The country suffers rolling power cuts for up to 18 hours a day. The government charges consumers less for the power than it costs to produce, but it doesn't have enough money to subsidize the producers, trapping the sector in a debt cycle.

The outages have crippled the country's industrial base, particularly textile factories, and serve as a daily reminder of the state's inability to take care of its citizens. As air conditioners are switched on this summer, record power cuts are being forecast — along with added social unrest in a country already creaking under assault from Islamist militants.

The government, which devotes most of its attention to political survival, has done nothing to address the causes of the energy crisis since it took power four years ago.

Back in 2006, the government of Pervez Musharraf pitched what it thought was a short-term solution to the problem — granting small power plants contracts of between three and five years, while it worked on longer-term projects like hydroelectric power.

Walters saw an opportunity and teamed up with one of the country's wealthiest businessman, Iqbal Ahmed, to exploit the demand for power. Ahmed's family company is Pakistan's biggest producer of natural gas and was close to Musharraf.

President Asif Ali Zardari continued with the so called "rental power projects" when he took office. By April, Walters Power International or its local partner had contracts to run three stations and was aiming to build one of Pakistan's largest power generation portfolios.

Under the deals, the companies received multimillion dollar payments in advance. But in many cases the government failed to provide gas to run them. With the plants not producing and the frequency of power outages increasing nationwide, the deals that led to them came under scrutiny from the media, the opposition and anti-corruption agencies.

"The government knew there was no gas. Walters knew there was no gas," said Khwaja Mohammad Asif, one of two lawmakers who petitioned the Supreme Court asking it to investigate the projects. "There is overwhelming evidence that these were scams from the word go."

Walters denied any wrongdoing and said the contracts were vetted by seven government agencies before it was signed. He said he never had any reason to doubt the government would provide gas, and said the advance and guaranteed payments were standard in such power arrangements around the world.

One of his prize plants was in Naudero in Sindh province. The $70 million plant was inaugurated by Zardari, who touted it as part of the solution to the energy crisis. It was supposed to provide power to local towns and villages and for wells vital to agriculture in the area, but it ran only to a fraction of its capacity. Hours after the Supreme Court ruling, it was shut down. Walters now says he can't get permission to recover the machinery from the site.

He said the opposition and the court were trying to score political points.

"Calling it a scam is nothing but an effort to embarrass the government by two members of parliament who managed to get the Supreme Court on their side," said Walters.

It's a similar story with the other foreign investor to take up the offer. Turkish company Karkey Karadeniz Elektrik Uretim invested $350 million in hulking floating power barges that were moored off the port city of Karachi. They started operations in April last year, but they were supplied little or no gas. The Supreme Court ruling ordered the company to repay a $180 million advance it was paid by the government. In a statement, Karky said it had started arbitration proceedings against the government and that the court ruling contained several material and factual errors.

The Supreme Court investigated the projects under so-called "suo moto" provisions, which allows it to initiate cases based on the "public interest," instead of waiting for cases appealed from lower courts to land in its docket.

It has passed similar orders on the price of sugar and established commissions to recover written-off loans, areas of economics and policy that some say should rarely be its business.

Saleem Mandviwalla, the head of Pakistan's Investment Board, said he was bewildered by the latest court order.

"This will not only effect the power business, but every business," he said. "All it has done has created more problems for Pakistan."

A recent report by the International Commission of Jurists said that the court was using "suo moto" investigations excessively, and that "when they are inappropriately applied, they may upset the balance of power and interfere with the ordinary course of justice."

But in a country where even government supporters admit that it has done nothing to curb corruption or make policy, some say that the Supreme Court is their only hope.

"All in all, they shouldn't be looking at this stuff, but if you were going to kill any policy, this would probably be it," said Feisal Naqvi, a lawyer and blogger. "The rental power policy was asinine."