The government's power to remove price controls on some natural gas was upheld yesterday by the Supreme Court in a ruling that gas producers said will mean billions of dollars in savings to consumers.

But the 8-0 decision is a defeat for pipeline companies that said it will mean some consumers now must continue to pay higher energy bills.

The court reinstated federal regulations that let gas producers raise some prices charged to pipeline companies, overturning a federal appeals court ruling that declared the rules invalid but allowed them to remain in effect pending yesterday's decision.

The focus of the natural gas case was the adoption in 1986 by the Federal Energy Regulatory Commission (FERC) of rules that let producers of so-called old gas raise their prices and stop selling to pipeline companies unwilling to pay higher prices. Old gas is defined by a 1978 federal law as natural gas committed to interstate commerce by Nov. 8 of that year, the date the law took effect.

Carter Phillips, a lawyer for the producers, hailed the ruling. He said it averts "a real mess" by assuring that contracts between producers and pipeline distributors will be honored.

"There would have been real turmoil in the industry" if the high court struck down the FERC rules, he said. "The nation probably dodged a bullet."

FERC and the gas producers said in their appeal to the high court that lifting price controls will spur new gas production that could save consumers $25 billion. But pipeline companies have said if the regulations were invalidated some consumers could be entitled to refunds of more than $100 million.

While the 1986 FERC regulations raised the maximum permissible price of old gas, little gas has been sold at the ceiling figure because of a depressed market in which supply exceeds demand.

Gas producers also said that in practice the price of some old gas actually declined and that the average price of gas nationwide dipped after FERC lifted the ceiling.

The 5th U.S. Circuit Court of Appeals ruled in 1989 that FERC exceeded its authority in lifting the price ceiling and adopting other regulations affecting the industry.

But Justice Byron R. White, writing for the Supreme Court, said yesterday that Congress gave the agency broad power. He rejected the argument that a portion of the 1978 law dealing with new gas suggests that Congress intended to limit FERC's powers.