WASHINGTON — After months of debate and negotiation, Congress voted final approval Wednesday to a massive farm bill that will provide more than $400 billion for agriculture subsidies, conservation programs and food aid.

The House voted 369-47 for the legislation, which sets federal agricultural and food policy for five years, after the Senate approved it 87-13 on Tuesday. It is now headed to the desk of President Donald Trump, who is expected to sign it.

The measure reauthorizes crop insurance and conservation programs and pays for trade programs, bioenergy production and organic farming research. It also reduces the cost for struggling dairy producers to sign up for support programs and legalizes the cultivation of industrial hemp.

House Agriculture Committee Chairman Rep. Michael Conaway, R-Texas, said the final bill looks at "stresses and strains across all of rural America, economic development issues and just the practice of farming and ranching. It says: here are federal resources we want to put against those problems."

One thing the bill doesn't include: tighter work requirements for food stamp recipients, a provision of the House bill that was celebrated by President Donald Trump but became a major sticking point during negotiations.

Another contentious piece of the House's original legislation, relaxing restrictions on pesticide use, also didn't make it into the final text.

Conaway championed the stricter work requirements, and fought to restrict the ability of states to issue waivers to exempt work-eligible people. The House measure also sought to limit circumstances under which families who qualify for other poverty programs can automatically be eligible for SNAP, the Supplemental Nutrition Assistance Program, and earmarked $1 billion to expand work-training programs.

The bill does increase funding for employment and training programs from $90 million to $103 million.

The original House bill failed during its first floor vote when 30 GOP members blocked it over an unrelated immigration issue. It passed a second time around, but without any support from Democrats, who insisted they wouldn't vote for a bill with the new work requirements included.

House Agriculture Committee Chairman Mike Conaway joined, from left, by Rep. Cathy McMorris Rodgers, Rep. Paul Ryan, and Rep. Kevin McCarthy speaks about the farm bill during a news conference on Capitol Hill on May 16, 2018. J. Scott Applewhite / AP file

"The version we passed in June took bold steps to reforming SNAP and moving in the direction most of us believed was supported by the American people," Conaway said. "That was not supported broadly by the body across the building, and we made the compromise necessary to get us to this place."

The House and Senate also clashed over portions of the bill's forestry and conservation sections.

Negotiations were complicated in recent weeks when the White House asked Congress to make changes to the forestry section in response to deadly wildfires in California, giving more authority to the Agriculture and Interior departments to clear forests and other public lands. The final text doesn't significantly increase the agencies' authority.

Agriculture Secretary Sonny Perdue said the bill will help producers "make decisions about the future, while also investing in important agricultural research and supporting trade programs to bolster export." But he voiced disappointment over the failed changes to work requirements.

"While I feel there were missed opportunities in forest management and in improving work requirements for certain SNAP recipients, this bill does include several helpful provisions and we will continue to build upon these through our authorities," he said.

The bill maintains current limits on farm subsidies, but includes a House provision to expand the definition of family to include first cousins, nieces and nephews, making them eligible for payments under the program.