Speaker of the House Paul D. Ryan (R-Wis.) expresses support for the work of the Agriculture Committee in crafting the farm bill at a news conference on Wednesday.  (J. Scott Applewhite/AP)

The House on Thursday easily defeated a controversial amendment to reduce sugar prices that had threatened to sink the entire farm bill if it had been included.

The 137-to-278 vote followed heated debate on the House floor, with the amendment’s supporters attacking a “Soviet-style” support system propping up sugar prices. Opponents argued the amendment’s passage would harm family farmers and send sugar production to countries that use child labor and pollute with abandon.

Behind the scenes, Agriculture Chairman K. Michael Conaway (R-Texas) had led a frenzied effort to defeat the provision. Conaway described the sugar amendment as a “poison pill” in his effort to pass the broader farm bill, which would reauthorize numerous agriculture and nutrition programs for five years, while toughening up work requirements for food stamp recipients.

“It puts Republicans who represent rural America in a really difficult spot to vote for a farm bill that goes after one of the commodities in the fulsome way that it does,” Conaway warned in an interview ahead of the vote.

The sugar measure, sponsored by Rep. Virginia Foxx (R-N.C.), was the most controversial amendment allowed to come to a vote as the House debates the farm bill ahead of a final passage vote set for Friday.

It would have begun to dismantle the sugar support program, eliminating production limits for U.S. growers and opening the door for more imports. It would also have ended a USDA program that buys up surplus sugar from domestic growers and resells it to bioenergy producers.

But its defeat does not necessarily pave the way for passage of the overall farm bill, which has become tangled up in an unrelated debate over immigration. Members of the conservative Freedom Caucus are threatening to withhold support for the farm bill as they try to extract commitments from GOP leadership on immigration. How — or if — that dispute would get resolved in time to pass the farm bill on Friday remained uncertain.

President Trump registered his support for the farm bill Thursday evening on Twitter, writing: “Tomorrow, the House will vote on a strong Farm Bill, which includes work requirements. We must support our Nation’s great farmers!”

Democrats are expected to vote against the farm bill unanimously because of their opposition to the new food stamp work requirements, so Republicans have to lock down the majority vote needed to pass the legislation from their side of the aisle alone. But despite their opposition to the overall farm legislation, large numbers of Democrats, led by Rep. Collin C. Peterson (Minn.), top Democrat on the Agriculture Committee, joined with Republicans to defeat the Foxx amendment.

Defeat of the amendment was a victory for GOP leaders over a coalition of conservative lawmakers egged on by free-market allies like the Heritage Foundation who object to the complex price controls that uniquely surround the sugar program. The debate also split lawmakers from states like Michigan and Minnesota that are home to sugar producers, against those from places including Pennsylvania — home to Hershey — and other food-producing areas that would benefit from lower sugar prices.

Lobbyists on both sides have flooded Capitol Hill. Even after Foxx rewrote her amendment to remove some of the most controversial language going after sugar protections, the American Sugar Alliance remained strongly opposed. Foxx and other lawmakers have tried unsuccessfully for years to overhaul the program, also falling short five years ago during debate on the last farm bill. But that time the vote was much closer, leading to anxiety among leadership that opponents of the sugar program could succeed this time around — fears that proved unfounded.

“Let’s be crystal clear about what the sugar program does,” Foxx said on the floor ahead of the vote. “It puts the government in charge of deciding how much sugar will be produced in this country, which inflates the cost, and it guarantees the processing industry a base profit by giving them subsidized loans. We stopped these practices years ago for other commodities, and only sugar is left with this sweet deal.”

Conaway hotly disputed those claims.

“She singles out sugar, cuts its program back to where it was 33 years ago, denigrates the hard-working men and women, the farmers,” he said in floor debate. “She couldn’t be more wrong or more disrespectful of them. Her amendment would not save the taxpayer one dime.”

In a separate farm bill amendment vote Thursday, the House narrowly passed a measure by Rep. Don Young (R-Alaska) to exempt national forests in Alaska from the “roadless rule” that prohibits road construction and timber harvesting on tens of millions of acres in the National Forest System. The amendment looked like it was going down, but the vote was kept open as Young prowled the House floor in search of support, ultimately convincing retiring Rep. Ryan Costello (R-Pa.) to flip from “no” to “yes.” The measure passed 208-207.

On the sugar program, the federal government has supported the U.S. sugar industry since 1981 through import quotas, marketing allotments and price-support loans, all designed to protect growers and processors against competition from countries such as Mexico. Sugar producers can, for instance, take out low-interest government loans to cover planting costs, then forfeit that sugar to the government if prices fall.

Sugar beets are widely grown in the Plains states, while sugar cane is still cultivated in Florida, Texas and Louisiana. Those growers, as well as moneyed sugar processors such as the American Crystal Sugar Company and the Fanjul Corporation, have argued they need price supports to compete against subsidized foreign production.

But the program has pitted producers against foodmakers who say it has pushed the cost of sugar up and cut into their margins. The makers of Life Savers, Dum Dums and Jelly Belly have all opened factories overseas, citing the high cost of American ingredients.

It has also attracted the ire of influential conservative think tanks, including the American Enterprise Institute and Heritage Foundation, which have condemned the program as the “very antithesis of a free market” and urged lawmakers to end it.

“Our federal sugar program is designed to drive up the price of sugar in the U.S. to profit a small handful of politically connected sugar moguls in Florida,” wrote Timothy Carney, a visiting fellow at the American Enterprise Institute. “It is perhaps the least defensible corporate welfare boondoggle on the federal books.”

A 2011 report by the U.S. International Trade Commission found that liberalizing America’s sugar trade policies would give the economy a $49 million boost, largely in the form of increased food sales.

The farm bill, which expires Sept. 30, covers a huge package of policies on nutrition, farming and rural development, from funding for agricultural research and rural broadband expansion to the food stamp program. Dozens of amendments have been offered and debated on the legislation, which affects nearly every lawmaker’s district.