The five-year bill, which preserves generous crop subsidies, heads to the Senate, where approval seems certain. The White House said President Barack Obama would sign it.
The measure, which the House approved 251-166, had backing from the Republican leadership team, even though it makes smaller cuts to food stamps than they would have liked. After wavering for several years, the GOP leaders were seeking to put the long-stalled bill behind them and build on the success of a bipartisan budget passed earlier this month. Leaders in both parties also were hoping to bolster rural candidates in this year's midterm elections.
House Speaker John Boehner did not cast a vote on the bill, a commonplace practice for a speaker, but he had issued a statement Monday saying it was "worthy of the House's support." Minority Leader Nancy Pelosi, D-Calif., voted for the bill despite concerns from some in her caucus that the bill cut too much from the food stamp program.
The bill ultimately would cut about $800 million a year from the $80 billion-a-year food stamp program, or around 1 percent. The House had sought a 5 percent cut.
The legislation also would continue to heavily subsidize major crops for the nation's farmers while eliminating some subsidies and shifting them toward more politically defensible insurance programs.
House Agriculture Chairman Frank Lucas, R-Okla., called the compromise a "miracle" after trying to get the bill passed for almost three years. An early version of the legislation was defeated on the House floor last June after conservatives said the food stamp cuts were too modest and liberal Democrats said they were too deep.
The House later passed a bill with a higher, $4 billion cut, arguing at the time that the program had spiraled out of control after costs doubled in the last five years. But cuts that high were ultimately not possible after the Senate balked and the White House threatened a veto. The Senate had sought a cut of $400 million annually.
Many House conservatives still voted against the bill - 63 Republicans opposed it, one more than in June.
One of those conservative opponents was Rep. Marlin Stutzman, R-Ind. "It spends money we simply don't have," he said.
But 89 Democrats supported it, bolstered by the lower cut in food stamps. The top Democrat on the agriculture panel, Minnesota Rep. Collin Peterson, said he also enticed some of his colleagues with more money for fruit, vegetable and organic programs.
The final savings in the food stamp program would come from cracking down on some states that seek to boost individual food stamp benefits by giving people small amounts of federal heating assistance that they don't need. That heating assistance, sometimes as low as $1 per person, triggers higher benefits, and some critics see that practice as circumventing the law. The compromise bill would require states to give individual recipients at least $20 in heating assistance before a higher food stamp benefit could kick in.
Some Democrats said the food stamp cut still is too high.
Rep. Jim McGovern of Massachusetts, one of the states that have boosted benefits through heating assistance, said the cut will be harmful on top of automatic food stamp cuts that went into place in November.
"I don't know where they are going to make that up," McGovern said.
To pass the bill, Lucas and his Senate counterpart, Democratic Sen. Debbie Stabenow of Michigan, found ways to bring many potential naysayers on board. They spent more than two years crafting the bill to appeal to members from all regions of the country. They included a boost in money for crop insurance popular in the Midwest; higher rice and peanut subsidies for Southern farmers; and renewal of federal land payments for Western states.
They also backed away from repealing a catfish program - a move that would have angered Mississippi lawmakers - and dropped House language that would have thwarted a California law requiring all eggs sold in the state to come from hens living in larger cages. Striking out that provision was a priority for California lawmakers who did not want to see the state law changed.
For those seeking reform of farm programs, the legislation would eliminate a $4.5 billion-a-year farm subsidy called direct payments, which are paid to farmers whether they farm or not. But the bill nonetheless would continue to heavily subsidize major crops - corn, soybeans, wheat, rice and cotton - while shifting many of those subsidies toward more politically defensible insurance programs. That means farmers would have to incur losses before they could get a payout.
The almost $100 billion-a-year bill would save around $1.65 billion annually overall, according to the Congressional Budget Office. The amount was less than the $2.3 billion annual savings the agriculture committees originally projected for the bill.
An aide to Lucas said the difference was due to how the CBO calculated budget savings from recent automatic across-the-board spending cuts, known as sequestration.
Associated Press writer Darlene Superville contributed to this report.