Beneath the jungles and volcanoes of the Indonesian archipelago are buried some of Asia's richest treasures -- vast deposits of gold, copper, coal and other natural resources. But foreign companies have all but stopped investing in new operations to mine them.

Despite huge reserves of oil and natural gas, Indonesia faces the prospect in the next few years of crippling power outages, like those that darkened most of the capital for two days last month. No new power stations are being built on the main Java-Bali electric grid. Foreign investors, whose money is needed for projects of this size, say they are not interested in developing new plants.

In both the mining and power industries, investors say that the poverty of Indonesia's legal system is a major part of why they're staying away. It has contributed to a general lack of confidence that is draining away badly needed capital and undermining the country's struggle to recover from the 1997-98 Asian financial crisis.

Foreign investors complain they are subject to the arbitrary demands of government officials, tax collectors and local partners. They have little meaningful recourse in the courts, where bribery is rampant and favoritism the legal standard.

Domestic and foreign businessmen alike also complain that judges routinely fail to enforce contracts. Even some local Indonesian entrepreneurs, wise in the ways of their country's courts, said they have been taken aback by the audacity of recent rulings, such as one in which a Canadian insurance company that said it was solvent and profitable was almost forced into bankruptcy by former Indonesian partners.

"Investors in Indonesia doubt whether their rights will be preserved and about the sanctity of contracts," said Hikmahanto Juwana, a professor of international economic law at the University of Indonesia. "The main thing is that Indonesia is no longer a good place to invest."

For the first seven months of this year, the amount of foreign direct investment approved by the Indonesian government declined 50 percent compared with the same period in 2001, which itself showed a sharp decrease from a year earlier, according to the government's figures. In part this stems from a global economic slowdown, rising labor costs and fears of political instability. But investors say it's hard to overstate how the legal problems of doing business here keep them away.

As a result, capital is leaving. According to the central bank, the country suffered a net capital outflow last year of $5.7 billion.

"The international economic climate is very gloomy right now and investors, being very cautious, only want clear and transparent possibilities," said James W. Castle of CastleAsia, a business consulting firm in Jakarta with multinational clients. "In this climate, they say maybe Indonesia isn't the right place for us right now."

Indonesia's sluggish recovery, trailing those of some Southeast Asian neighbors, reflects a broader problem confronting the country as it seeks to build a working democracy four years after protesters forced President Suharto from office after 31 years of rule: the failure to establish the rule of law.

The car bombing in Bali earlier this month that killed more than 180 people has made it even more urgent that Indonesia tackle its flawed legal system, according to Andrew Steer, country director for the World Bank. The bomb hurt Indonesia's tourism industry, an important engine of economic growth, but the greater damage was to investor confidence, he said.

"Business confidence is less likely to recover" because of the attack, Steer said. "What is business confidence all about? It's about predictability in the business climate, that contracts will be enforced and the rule of law is clear to everyone."

During the long rule of Suharto, Indonesia was famed for nepotism and corruption, especially involving his children and closest associates. But businessmen knew that if they struck a deal with one of these insiders -- perhaps part ownership of a new venture or a generous kickback -- government protection would be assured.

That certainty, underpinned by fear and coercion, has yet to be replaced in post-Suharto Indonesia by the sort of legal guarantees that exist in more mature and developed market economies. Although the Indonesian government has taken substantial strides in the last four years toward consolidating a multiparty democracy and decentralizing power, businessmen and political analysts say that establishing rule of law remains a low priority.

Indonesian general elections are due in two years, and analysts say this is one reason why politicians are not rushing to change the system. Political parties are looking for ways to peddle their influence in return for campaign funds, and politicians will have little incentive to wring corruption out of the legal system, said corporate lawyer Luhut M.P. Pangaribuan.

Mahendra Siregar, an adviser to Indonesia's economics minister, said recent high-profile scandals are a symptom of his country's rapid transition to democracy and serve as an unavoidable reminder to members of the public that they cannot take legal reform for granted. "The fact there are still many cases that produce surprising and shocking results is something we have to deal with," he said.

The most jarring example, foreign investors say, came this summer. A three-judge panel held that the local unit of Canadian insurer Manulife Financial Corp. was bankrupt, even though the company insisted it was still solvent.

The ruling came in response to a claim by Manulife's former Indonesian partner in a joint venture, which had been seeking to win millions of dollars through the bankruptcy process. After the ruling, Manulife claimed it had been the victim of a "public mugging."

For a time, it seemed the local Manulife unit, which has 4,000 employees and 400,000 policyholders in the country, would have to close, even though it had assets now worth about $522 million and profits in its insurance business that exceeded $8 million last year, according to Syarifudin Yunus, Manulife's local spokesman.

The Canadian government threatened sanctions. U.S. and other diplomats in Jakarta launched a petition drive on behalf of the company, raising their objections directly with President Megawati Sukarnoputri.

A month later, facing intense political pressure, the Supreme Court overturned the decision. The three judges who declared the unit bankrupt were suspended on suspicion of taking bribes.

Foreign and Indonesian corporate executives said the Manulife decision was unique only for the extensive political fallout that forced a reversal of the decision.

"In almost every way, the law is manipulated. If we are truly interested in restoring our economic development, the most important thing is certainty in the implementation of the law," said Eddie Lembong, who runs Pharos Indonesia Ltd., a big pharmaceutical company.

Early last year, the International Finance Corp., the commercial arm of the World Bank, stopped lending money to private companies here because of concerns over judicial corruption, according to German A. Vegarra, the corporation's country manager. He said the agency is now considering resuming loans, but on a highly selective basis.

The reluctance of the mining industry to put money into the country has been heightened by rulings against its own companies.

Earlier this year, the South Jakarta District court froze the assets of Kaltim Prima Coal, one of Indonesia's richest coal mines, during a battle among different parts of the Indonesian government over its ownership.

KPC, jointly owned by BP and the Anglo-Australian mining giant Rio Tinto, had previously agreed to turn over a 51 percent share to a government entity, but it was never clear which entity would get the shares. When the provincial government of East Kalimantan pressed to gain a majority interest, KPC was caught in the middle and had its assets frozen. Ultimately, Megawati herself had to weigh in to break the deadlock.

In the power industry, foreign executives said it is hard to get financing for new generating stations in part because of concerns that contracts signed with local partners will not be respected. Rambun Tjajo, an Indonesian lawyer, said local businessmen know how to outmaneuver foreign investors, based on years of experience and connections. In some cases, Tjajo said, Western companies cannot compete at all because anti-corruption laws in their home countries preclude giving bribes.

In hopes of insulating themselves from Indonesian courts, some investors have insisted that contracts contain provisions for international arbitration of disputes. But that didn't work in the case of Karaha Bodas Co., an energy firm owned mainly by U.S. investors that signed an agreement in 1994 with the Indonesian state oil company, Pertamina, to jointly operate a geothermal power plant.

The Indonesian government canceled the project five years later and Karaha Bodas took the case to an international arbitration court in Geneva, where it won a $261 million award. But Pertamina balked at paying and the courts here threw out the arbitration ruling.