WASHINGTON (AP) — Congress is poised to send a massive, five-year farm bill that provides food for the needy and subsidies for the nation’s farmers to the White House for President Barack Obama’s signature.

The Senate was expected to pass the almost $100 billion-a-year compromise bill Tuesday; the House passed it last week. The bill provides a financial cushion for farmers who face unpredictable weather and market conditions, while also continuing to subsidize services for rural residents and communities who have hit hard times in recent years. The majority of the bill’s cost is food stamps, which supplement meal costs for 1 in 7 Americans.

House Republicans had hoped to trim the bill’s costs, pointing to a booming agriculture sector in recent years and saying the now $80 billion-a-year food stamp program has spiraled out of control. Partisan disagreements stalled the bill for more than two years, but conservatives were eventually outnumbered as the Democratic Senate, the White House and a still-powerful bipartisan coalition of farm-state lawmakers pushed to get the bill done.

The final compromise bill would get rid of controversial subsidies known as direct payments, which are paid to farmers whether they farm or not. But most of that program’s $4.5 billion annual cost was redirected into new, more politically defensible subsidies that would kick in when a farmer has losses. The food stamp program was cut about 1 percent; the House had pushed for five times that much.

Senate Agriculture Chairwoman Debbie Stabenow, D-Mich., said Monday that she and her House counterpart, Rep. Frank Lucas, R-Okla., tried to craft a bill that would work for all regions of the country, “from traditional row crops, to specialty crops like fruits and vegetables, to livestock, to organics, to local food systems.”

Those incentives scattered throughout the bill — a boost for crop insurance popular in the Midwest and higher subsidies for Southern rice and peanut farmers, for example — helped the bill pass easily in the House last week, 251-166. House leaders who had objected to the legislation since 2011 softened their disapproval as they sought to put the long-stalled bill behind them. Leaders in both parties also have hoped to bolster rural candidates in this year’s midterm elections.

The final savings in the food stamp program, $800 million a year, 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 still objected to the cuts, even though they are much lower than what the House had sought. The Senate-passed farm bill had a $400 million annual cut to food stamps. “This bill will result in less food on the table for children, seniors and veterans who deserve better from this Congress, while corporations continue to receive guaranteed federal handouts,” Sen. Kirsten Gillibrand, D-N.Y., said. “I cannot vote for it.”

At the same time, some Republicans took to the Senate floor Monday to say the bill costs too much and doesn’t do enough to trim spending. “It’s mind-boggling, the sum of money that’s spent on farm subsidies, duplicative nutrition and development assistance programs, and special interest pet projects,” Sen. John McCain, R-Ariz., said.

Sen. Charles Grassley, R-Iowa, a longtime member of the Agriculture Committee, said he would vote against the bill because the compromise does not include provisions he authored to reduce the number of people associated with one farm who can collect farm subsidies. Grassley has for years fought to lower subsidies to the wealthiest farmers.

The bill does have a stricter cap on the overall amount of money an individual farmer can receive — $125,000 in a year, when some programs were previously unrestricted. But the legislation otherwise continues a generous level of subsidies for farmers.

In place of the direct payments, farmers would now be able to choose between subsidies that pay out when revenue drops or when prices drop. Cotton and dairy supports were overhauled to similarly pay out when farmers have losses. Those programs may kick in sooner than expected as some crop prices have started to drop in recent months.

The bill would save around $1.65 billion annually overall. But critics said that under the new insurance-style programs, those savings could disappear if the weather or the market doesn’t cooperate. Craig Cox of the Environmental Working Group, an organization that has fought for subsidy reform for several years, said replacing the direct payments with the new programs is simply a “bait and switch.”

“The potential for really big payoffs” is huge, he said.

Follow Mary Clare Jalonick on Twitter: http://twitter.com/mcjalonick