The House unexpectedly and overwhelmingly defeated a sugar price support bill yesterday that opponents said would have cost consumers at least $400 million a year.

The final vote of 249 to 158 found an unusual coalition of consumer liberals joining with conservatives to rout proponents of the carefully crafted bill.

Proponents included President Carter, whose administration termed the bill a compromise that would assure long-term price stability while protecting American sugar cane and beet producers from lower priced imports.

Also caught in the backwash were the chairmen of the Agriculture and Ways and Means committees, Thomas S. Foley (D-Wash.) and Al Ullman (D-Ore.), who put their prestige on the line by strongly supporting the measure.

In the end, they were overwhelmed by one of those political juggernauts that occasionally rolls through the Congress -- a blend of powerful industrial users of sugar and an array of consumer and labor organizations.

Foley lamented that the bill had been subjected to arguments with "more exaggeration and less basis in fact" than any farm-related measure he had dealt with in the House.

Even though he, Ullman and other supporters called it a moderate plan to defend the consumer from short supply and precipitous price increases in the future, it was not enough.

The bill proposed to do that by giving cane and beet growers a direct subsidy payment of one-half cent per pound, and by setting a price support of 15.8 cents per pound. The current price is 15 cents.

The direct payment, from fees the Treasury would collect on imported sugar, and the price support increase would have meant an additional consumer cost of at least $400 million yearly, opponents said.

One of the most active opposition leaders, Rep. Margaret Heckler (R-Mass.), termed the bill "a ripoff by giant corporations, a ripoff of the consumer, who is already on the ropes of inflation."

Another 11th-hour opponent, Rep. Charles A. Vanik (D-Ohio), after losing efforts to modify the bill, called it a measure "whose time has come and gone." He described it as "a sweet one-way street for the grower."

He was joined in last-minute opposition by another influential member of Ways and Means, Rep. Bill Frenzel (R-Minn.), who was defeated by 10 votes in an earlier effort to kill the direct payment scheme.

"We ought to have a little more respect for the taxpayers," Frenzel said after that amendment and a variation of it were defeated.

But opponents, led by Heckler and Rep. Peter Peyser (D-N.Y.), were setting an ambush. Peyser was urging defeat of the Frenzel modifiers in order to make the measure less palatable on final passage.

Left in the wreckage was a provision that would have authorized the president to implement U.S. participation in the International Sugar Agreement (ISA), an 80-nation compact designed to regulate world sugar trade.

U.S. participation was contingent upon congressional approval of the implementing legislation. Vanik said yesterday's House action will create "great uncertainty" among foreign sugar producers and that he will make an effort to come up with a new bill soon dealing only with U.S. participation in ISA.

Among those elated at yesterday's surprisingly harsh vote against the bill was Kathleen F. O'Reilly, executive director of the Consumer Federation of America, which played a key lobbying role.

"Less than 1 percent of the nation's farmers are even affected by this bill," O'Reilly said. "Today's vote gives consumers specific and significant evidence of where their representatives stand in the fight against food inflation."