For eight years Palo Alto, Calif., officials watched in frustration as refuse piled up outside their modernistic sewage plant, too fine to dump into land fills and not safe enough to use as a fertilizer.

Then a group of four Northern Virginia investors made the city a bizarre offer: They'd take the plant's sludge wastes and plunk gold and other precious metals out of it.

Yesterday, almost a year after a McLean firm known as World Resources signed an angreement with the city, Palo Alto officials said the idea is working and their city is $1 million richer. "They got rid of our disposal problem and turned the sludge into an asset," said Mark Harris, Palo Alto treasurer.

World Resources, which says it has a corner on the sludge-to-precious-metals market, last month expanded its operation to Attleboro, Mass., and two days ago signed a contract to seek gold in the sludge of Warwick, R.I. "In the future we hope to locate more sources of metals in the sludge that is now going into landfills and to recover a greater amount of precious metals," said Paul E. Barrick, vice president of the company.

City officials said the company agreed to process the sludge after a chemical analysis showed heavy concentrations of precious metals in their sewage wastes.

In Palo Alto, for example, Harris said there is a large amount of gold and silver residues in the city's sewerage system from the numerous electronic and photo processing firms along the San Francisco Peninsula.

The city gets a royalty based on the amount and concentration of the metals removed from the sludge ash. Harris said the city receives anywhere from 15 to 80 percent of the gross value of the gold and silver, based on a formula in the city's contract.

The Palo Alto treatment plant converts 30 million gallons of sludge daily into four tons of ash by burning it. Each ton of ash produces about 20 ounces of silver and one ounce of gold through the secret process, Harris said.

City officials said the entire operation grossed more than $2 million last year, with World Resources getting $1 million. "I'm sure they did a lot better than they expected with the way the gold and silver market went this year," said Harris. "Three or four months ago, the revenues were out of sight."

World Resources officials are hesitant to discuss the particulars of their business, but Barrick said the company developed the process with several laboratories.

Warwick officials say they are ecstatic about their contract with World Resources. Mayor Joseph Walsh estimates the city will save $40,000 a year in sludge removal and disposal costs, and make about $10,000 from the extraction process. World Resources will also spend $100,000 to build a greenhouse to dry the sludge before it is burned.

"It's a novel, innovative program and a saving for the taxpayers," said Walsh, adding, "It's a windfall. There's no commitment of our part."