The Senate on Thursday completed 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."

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 by 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.

Farm bills traditionally have been bipartisan efforts, and leaders of the Senate Agriculture, Nutrition and Forestry Committee leaders made a point of showing how their bill would bring down the deficit.

While overall spending on programs covered by the bill has climbed because more people are receiving food stamps, the committee head, Sen. Debbie Stabenow, D-Mich., and the top Republican, Sen. Pat Roberts of Kansas, said the bill would save $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.

The biggest change comes from eliminating direct payments to farmers whether they plant crops or not. The program, which costs about $5 billion a year, has lost much of its support at a time of $1 trillion federal deficits and when farmers in general are prospering.

That subsidy, and a separate one where the government sets target prices and pays farmers when prices go below that level, will be replaced. There will be greater reliance on crop insurance and a new program that covers smaller losses on planted crops before crop insurance kicks in.

The bill also prevents farm "managers," often wealthy people who may not live or work on a farm, from receiving subsidy payments and gives greater help to fruit and vegetable producers and healthy food programs.

The Senate rejected several Republican amendments that would have reduced food stamp spending by such means as tightening up eligibility requirements.

The bill saves about $4 billion over 10 years, a small amount compared with the projected $770 billion in spending for food stamps over 10 years. It stops lottery winners and more affluent college students from receiving benefits and cracks down on benefit trafficking.

Agriculture Secretary Tom Vilsack praised the Senate bill for making progress toward "providing a reformed safety net for producers in times of needs," supporting agriculture research, conserving natural resources, strengthening local food systems and promoting jobs. He expressed hope the House "will produce a bill with those same goals in mind."

Rep. Frank Lucas, R-Okla., chairman of the House Agriculture Committee, said that while there will be differences between the House and Senate approaches, "I hope my colleagues are encouraged by this success." His committee is scheduled to meet on July 11 to vote on a House version of the bill.

The House must deal with a North-South divide on the bill that the Senate chose to leave for future negotiations.

The switch from direct payments to the revenue loss subsidy was welcomed by Northern and Midwestern corn and soybean farmers but strongly opposed by Southern rice and peanut growers. They traditionally have relied more on direct payments and targeted prices and want to keep parts of those subsidies. The House is expected to be more sympathetic to the Southerners.

While transforming the subsidy system, the Senate left intact the sugar program that for some 80 years has protected beet and sugarcane growers and sugar refiners by controlling prices and limiting imports.

The program is opposed by consumer groups and food and beverage companies that use sugar. They say it drives up costs and leads to confectioners relocating overseas. Amendments to either phase out or narrow the scope of the sugar program both failed on close votes.

In all, the Senate considered more than 70 amendments over three days. Among the more significant, the Senate approved, over the objections of Stabenow and Roberts, a measure that would reduce by 15 percentage points the share of crop insurance premiums the government pays for farmers with adjusted gross incomes of more than $750,000.

Sponsors of the amendments, Sens. Dick Durbin, D-Ill., and Tom Coburn, R-Okla., said that would affect only 1,500 of 1.5 million farmers and save $1 billion over the next decade. Stabenow and Roberts argued that it would result in fewer people buying insurance and more relying on ad hoc disaster relief.

Currently the government bears an average 62 percent of crop insurance premiums, and the Congressional Budget Office estimates that the crop insurance costs will be nearly $10 billion a year over the next 10 years.

The Senate on Thursday also narrowly rejected an amendment by Sen. Mike Johanns, R-Neb., that would have barred the Environmental Protection Agency from all aerial surveillance of agriculture operations.