Updated

The House of Representatives passed a sweeping, subsidy-packed farm bill on Thursday that tightens food stamp rules, in a major win for the House leadership after a day of setbacks and chaos on immigration.

The House bill narrowly passed by a vote of 213-211 with 20 Republicans voting no. It sets up a certain clash in the Senate, which looks to make mostly modest adjustments to existing programs and doesn't pick a food stamps fight.

The measure cuts federal food stamps benefits by some $9 billion over the next decade, and includes provisions strengthening work requirements for those who get the benefit.

Nonpartisan congressional estimates say nearly 4 percent of SNAP recipients -- some 1.2 million people -- would lose the benefits under the new farm bill.

But $6.7 billion of those savings would go to new work-training programs, which critics say are often ineffective, and nearly another $1 billion would be allocated to administrative costs.

Currently, adults 18-59 are required to work part time to receive food stamps, officially called the Supplemental Nutrition Assistance Program (SNAP), or agree to accept a job if they're offered one. Stricter rules apply to able-bodied adults 18-49, who are subject to a three-month limit of benefits unless they meet a work or job training requirement of 80 hours per month.

Under the new farm bill, the tougher requirement would be expanded to apply to all adults on SNAP, with exceptions for seniors, pregnant women, caretakers of children under 6, or people with disabilities.  Food stamp benefits average about $450 a month for a family of four.

“This bill includes critical reforms to nutrition benefits that close the skills gap, better equip our workforce, and encourage people to move from welfare to work, so more Americans have the opportunity to tap into the economic prosperity we’re seeing right now," House Speaker Paul Ryan said in a statement.

"This bill includes critical reforms to ... encourage people to move from welfare to work."

— House Speaker Paul Ryan

Democrats unanimously opposed the bill, saying it would toss too many people off government assistance.

CHAOS, CONFUSION MARK HOUSE GOP VOTES ON IMMIGRATION BILLS

The bill also includes major subsidies, particularly for soybean, wheat, cotton, rice, corn, and peanut farmers -- leading some critics to deride the legislation as little more than a substitution of food stamps with so-called "corporate welfare."

The House previously voted down the farm bill last month, with the conservative House Freedom Caucus withholding support without an agreement to hold a vote on an immigration bill.

But on Thursday, after the House leadership acceded to the Freedom Caucus' demands and put a hard-right immigration proposal to a vote, the farm bill passed with strong Republican support.

The conservative immigration measure was defeated 231-193, with 41 Republicans — mostly moderates — joining Democrats in voting against it.

Those defections — nearly one in five GOP lawmakers — underscored the party's chasm over immigration and the election-year pressures Republicans face to stay true to districts that range from staunchly conservative to pro-immigrant.

The failed immigration bill would have authorized -- but not fully appropriated -- $25 billion in border funding and provided nonimmigrant legal status to some 700,000 Deferred Action for Childhood Arrivals (DACA) recipients.

A vote is expected tomorrow on a compromise immigration bill that also faces long odds. It includes a pathway to citizenship for some illegal immigrants, and fully appropriates $25 billion for  President Trump's border wall plan.

The Associated Press and Fox News' Chad Pergram contributed to this report.