Many Republicans also voted no, but for a different reason. They said it was too expensive a bill to pass when the country has $17 trillion in debt.
In the final vote, 62 Republicans opposed the bill, and with the Democratic defections, that was enough to send it to defeat.
The final tally was delayed for several minutes as GOP leaders held the vote open, while Democrats called for the vote to close.
The vote is a blow to Speaker John Boehner (R-Ohio) and other Republican leaders who for two years have failed to move farm policy forward. The issue has badly divided Republicans.
Immediately after the vote, Republicans were apoplectic at what they characterized as a betrayal by Democratic leaders, who did not deliver the votes they promised.
"The Democrats walked away from this," Boehner, who cast a rare vote in favor of the bill, told The Hill as he walked off the House floor.
He would not answer further questions as he returned to his office.
The chief Republican vote-counter, Majority Whip Kevin McCarthy (Calif.), also blamed Democrats and said the bill could come back to the floor next week, with changes. "We can correct it if [Democrats] are not going to help us," he said after the vote.
Republicans had expected Democrats to deliver 40 votes for the bill. But a GOP aide said at the last moment, Agriculture Committee ranking member Collin Peterson (D-Minn.) said they could not produce that many because of pressure from Democratic leaders and the White House, which had threatened to veto the bill over the food stamp cuts.
Peterson blamed the approval of two amendments for the failure.
One of the amendments — backed by Boehner — ended production limits on dairy producers that were a part of the underlying bill.
The second, sponsored by Rep. Steve Southerland (R-Fla.), allowed states to require food stamp beneficiaries to either work or look for work.
"I told Cantor that Southerland cost us 15 votes," Peterson said, referring to Majority Leader Eric Cantor (R-Va.). "A lot of people came up to me and said, I'm with you, but I'm out now."
Rep. Steve King (R-Iowa), a conservative charged with whipping GOP votes for the bill, was surprised by the number of GOP defections.
"I was surprised by about half of them," he said. "I thought they would have taken more of a 10,000 foot view. We are ending direct payments in this bill, we are starting to reveres the obscene growth of the food stamp program."
King blamed key vote alerts from Heritage Action and Club for Growth for hurting the bill and also acknowledged that the Boehner-backed dairy amendment and Southerland food stamp work requirement cost key Democratic support.
King said that the path forward is unclear.
"There is going to be a staring contest now because unless Congress acts the 1949 farm bill goes back into effect," he said.
The 1949 law contains archaic farm subsidy supports seen as unworkable in today's world. Currently, rural America is using the 2008 farm bill which was retroactively extended in the New Year's fiscal cliff deal. It expires Sept. 30.
Democrats have blasted the $20.5 billion in food stamp cuts all week as cruel, while Republicans said more cuts are needed to eliminate fraud and ensure people aren't becoming dependent on the program.
"[W]hen we see the expansion of the dependency class in America, and you add this to the 79 other means-tested welfare programs that we have in the United States … each time you add another brick to that wall, it's a barrier to people that might go out and succeed," King said during Wednesday's debate.
Rep. James McGovern (D-Mass.) offered an amendment to restore the cuts, which was rejected in a 188-234 vote.
"It always is a wonderment to me, that in this, the greatest country that ever existed in the history of the world, that one in four or one in five children goes to sleep hungry at night," Minority Leader Nancy Pelosi (D-Calif.) said just before that vote, in an effort to encourage the additional funding.
This story was updated at 2:40 p.m.
Russell Berman contributed to this story.