The farm bill failed in the House Friday on a vote of 213 to 198. House GOP leaders had seemed confident as they walked into the vote Friday morning and believed they would have the support needed to pass the measure.

But the head of the conservative House Freedom Caucus, Rep. Mark Meadows, R-S.C., had warned that he was not able to convince any of his members to switch from a "no" vote to a "yes" vote on the giant agriculture and food bill. It was a message he conveyed in a phone call to GOP Whip Steve Scalise, R-La.

During the farm bill vote, all members of the GOP leadership — Speaker Ryan, Majority Leader McCarthy, Whip Scalise and Deputy Whip McHenry — could be seen negotiating on the floor with members of the Freedom Caucus.

Get Breaking News Delivered to Your Inbox

Democrats, who opposed the bill, cheered when the results were announced.

Two days before the farm bill was put on the floor for a vote, Freedom Caucus members began demanding that the House first vote on the conservative immigration legislation authored by Judiciary Committee Chairman Rep. Bob Goodlatte, of Virginia.

A leadership aide said that during negotiations, the group was seeking a vote on the Goodlatte bill before some of their more moderate Republican counterparts were able to force a vote on separate legislation. Although House Majority Leader Kevin McCarthy offered the Freedom Caucus a vote on its immigration legislation in early June, the group still refused to support the farm bill.

Another aide familiar with the negotiations said that some of the group's members, many of whom come from rural districts, privately said they wanted to vote for the farm bill, but wouldn't do so without Meadows. Meadows was an early "no" vote on the bill, along with his other co-chair, Rep. Jim Jordan, R-Ohio.

Rep. Scott Perry, R-Pa., a member of the House Freedom Caucus who voted against the farm bill, said that the group no longer trusted the leadership's promises.

"We've been waiting for months and months and months. [Spending bills] have come and gone, other issues have come and gone, and they've all said you'll get a vote on Goodlatte if you vote for this. We voted for and against this and that and we haven't had this vote on Goodlatte," he said. "We want this immigration issue dealt with and unfortunately the farm bill came at the wrong time."

While the farm bill does not expire until the end of September, it is the last must-pass piece of legislation before Congress considers the major spending bill to keep the government funded this fall.

McHenry said the demands were "not in our legislative capacity," and he criticized members who had said they would support the farm bill, and then voted no. Doug Andres, a spokesman for Speaker Ryan, said, "This is all the more disappointing because we offered the vote these members were looking for, but they still chose to take the bill down."

The concern among leadership is that the failed vote today just gives more fuel to a group of moderate House Republicans who have joined Democrats in trying to force a vote on a series of four immigration bills that range from the conservative Goodlatte bill to a version of the DREAM Act. The discharge petition currently has 196 signatories, and McHenry predicted it would be just "hours" before they hit the 218-signature threshold necessary to force a vote.

"The unfortunate thing is by this show today it gives more leverage on the discharge petition which I think is highly destructive," McHenry said. "I think Republicans in the majority need to resolve our vote on immigration, or a series of votes, and come to terms with it.

House Speaker Paul Ryan, R-Wisc., switched his vote from "yes" to "no" at the last minute, which allows him to file a motion to reconsider the vote at a later date. Chief deputy whip Patrick McHenry, R-N.C., told reporters he didn't know when that would be, though.

About half of Republicans who voted down the farm bill are members of the House Freedom Caucus, but there were also a few who are retiring, including New Jersey Reps. Rodney Frelinghuysen and Frank LoBioldo. "No" votes also included a couple of moderates who have signed the discharge petition to force an immigration vote. Republicans in this category include Reps. Ileana Ros-Lehtinen of Florida and John Katko of New York.

In addition to all of the Democrats who voted down the farm bill, here is the list of Republicans who also opposed it.