WASHINGTON – The Senate on Thursday passed a five-year, half-trillion-dollar farm bill that cuts farm subsidies and land conservation spending by about $2 billion a year but largely protects sugar growers and some 46 million food stamp beneficiaries.

The 64-35 vote for passage defied political odds. Many inside and outside of Congress had predicted that legislation so expensive and so complicated would have little chance of advancing in an election year.

Senate Republican leader Mitch McConnell called it “one of the finest moments in the Senate in recent times in terms of how you pass a bill.” Maine Sens. Olympia Snowe and Susan Collins, both Republicans, voted to approve the bill.

The bipartisanship seen in the Senate may be less evident in the House, where conservatives are certain to resist the bill’s costs, particularly for food stamps. Food stamp spending has doubled in the past five years, and beneficiaries have grown from about 20 million to 46 million. The program’s budget is now about $80 billion a year, comprising 80 percent of the spending in the farm bill.

Leaders of the Senate Agriculture, Nutrition and Forestry Committee leaders made a point of showing how their bill would bring down the deficit by saving $23 billion over the next 10 years, compared with spending under the current farm bill.

That comes from replacing four farm commodity subsidy programs with one, consolidating 23 conservation programs into 13, and ending several sources of abuse in food stamps. That program is called the Supplemental Nutrition Assistance Program, or SNAP.