WASHINGTON — House Republicans narrowly pushed through a bill on Thursday that slashes billions of dollars from the food stamp program, over the objections of Democrats and a veto threat from President Obama.

The vote set up what promised to be a major clash with the Senate and dashed hopes for passage this year of a new five-year farm bill.

The vote was 217 to 210, largely along party lines.

Republican leaders, under pressure from Tea Party-backed conservatives, said the bill was needed because the food stamp program, which costs nearly $80 billion a year, had grown out of control. They said the program had expanded even as jobless rates had declined with the easing recession.

“This bill eliminates loopholes, ensures work requirements, and puts us on a fiscally responsible path,” said Representative Marlin Stutzman, Republican of Indiana, who led efforts to split the food stamps program from the overall farm bill. “In the real world, we measure success by results. It’s time for Washington to measure success by how many families are lifted out of poverty and helped back on their feet, not by how much Washington bureaucrats spend year after year.”