Washington (CNN) The House on Thursday passed a $4.6 billion Senate bill to send emergency funding to the border, a vote that triggered outrage from progressives who objected to the legislation and an outpouring of emotion on the House floor. The measure, which passed 305-102, will next go to the White House for President Donald Trump's signature.

The vote provoked intense Democratic infighting and came after House Speaker Nancy Pelosi backed down from an effort to make changes to the legislation, saying instead that the House would "reluctantly" take up the Senate bill "to get resources to the children fastest." That announcement marked a reversal from her previous calls to reconcile the Senate bill with a measure passed by the House that progressives argued would have done far more to protect migrant children in government custody.

By pushing the legislation across the finish line, Pelosi demonstrated a willingness to defy the progressive wing of her party, but the debate proved to be one of the most significant tests of her ability to keep control of the House Democratic caucus since she took back the speakership.

The bill had previously passed the Senate by an overwhelming bipartisan vote. It will provide billions of dollars to be used to care for children in federal custody and does not include any funding for a border wall. It was the result of a compromise negotiated between Sen. Richard Shelby, the chair of the Senate Appropriations Committee, and Sen. Patrick Leahy, the top Democrat on the committee.

The White House made clear that it would veto the House version of the legislation and moderate House Democrats had ratcheted up the pressure on Pelosi to pass the Senate version by Thursday as Congress raced the clock to try to reach a deal before lawmakers left for the July Fourth recess.

Trump welcomed the bill's passage, tweeting that it was a "great job done by all!"

House progressives, however, criticized the Senate bill, arguing that they cannot trust the Trump administration not to divert money for humanitarian aid toward immigration enforcement, and that they needed to include more protections as well as higher standards of care.

Ninety-five Democrats voted against Thursday afternoon's bill, while 129 supported it. Seven Republicans opposed the measure, with 176 in favor.

An outpouring of emotion and Democratic infighting

At one point on Thursday, Democratic Rep. Mark Pocan, co-chair of the progressive caucus, was spotted in an intense discussion on the House floor with Democratic Rep. Max Rose of New York, a moderate House Democrat and a member of the problem solvers caucus.

The discussion came soon after Pocan had compared the caucus to child abusers, saying in a tweet , "Since when did the Problem Solvers Caucus become the Child Abuse Caucus? Wouldn't they want to at least fight against contractors who run deplorable facilities? Kids are the only ones who could lose today."

Pocan confirmed to reporters that Rose confronted him about the tweet, but Pocan continued to express frustration.

"I mean they have to be able to recognize why we're upset," Pocan said, arguing the moderate Democrats prioritized leaving for recess over supporting key provisions that progressives wanted in the Senate bill.

At another point, Rep. Veronica Escobar became emotional on the House floor as she talked about the photo released earlier this week of a father and daughter who drowned trying to cross the Rio Grande into the US. The Texas Democrat wiped away a tear at during her speech as her voice broke. The House then held a moment of silence on the floor for all migrants who have died at the border, including the father and child.

The shocking image went viral this week -- serving as a grim reminder of the dangerous journey migrants take to get to the United States -- and added even more urgency for Republicans and Democrats to make a deal.

Moderates pushed Pelosi

JUST WATCHED Mike Pence pressed on US-Mexico border facilities Replay More Videos ... MUST WATCH Mike Pence pressed on US-Mexico border facilities 03:31

The House unveiled an amendment to the $4.6 billion Senate bill late Wednesday , but Democratic moderates threatened to revolt and kill the latest border spending bill pushed by the House, according to two Democratic sources involved in the effort.

Behind the scenes, moderates were encouraging members of the Blue Dog and Problem Solvers caucuses to vote against a procedural vote that governed floor debate and force Pelosi to pass the bipartisan Senate bill, as the White House and Hill Republicans have been demanding.

Asked why he thought Pelosi ultimately decided to go with the clean bill, Rep. Henry Cuellar, said: "We cannot lead with a game of chicken," adding the House and Senate could not go back and forth on something as pressing as this.

Cuellar, a Democrat from Texas, said that for him, the growing distress at the border is happening at home. The congressman pulled out his phone and showed reporters images he'd been sent from constituents at the border.

"Listen, I don't go visit the border. I live at the border. Those men and women who sometimes get demonized. That is wrong. Those are my neighbors and I have their backs," he said.

Rep. Stephanie Murphy, a moderate member and refugee herself who is a chair of the Blue Dog Coalition, told reporters that she was upset by her progressive colleagues' accusations that moderates didn't care as much about the kids at the border because they were willing to vote for the Senate border supplemental.

"I think we have to try to get resources to the border as soon as possible. If you care about those children, then you need to be working to get resources at the border," she said.

Pelosi's decision making

On Wednesday, Pelosi signaled that she wouldn't concede to Senate Republicans, replying "no" when asked if the House would take up the Senate version of the aid package. On Thursday morning, however, she did not rule out the possibility of passing the Senate bill when asked at her weekly press conference, though she still insisted that she hoped to see changes to the legislation.

She spoke on the phone with Vice President Mike Pence for nearly an hour Thursday,a senior Democratic aide said, before meeting with her leadership team to brief them.

A source familiar with the matter explained that in exchange for the House taking up the bill, Pence promised administrative changes, including that members would be notified within 24 hours after the death of a child in custody and he agreed to the 90-day time limit on children spending time in an influx facility. The moves can be done by the administration.

"The children come first. At the end of the day, we have to make sure that the resources needed to protect the children are available," Pelosi wrote in a letter to her caucus on Thursday. "Therefore, we will not engage in the same disrespectful behavior that the Senate did in ignoring our priorities. In order to get resources to the children fastest, we will reluctantly pass the Senate bill."

Some Democrats outraged

JUST WATCHED Ocasio-Cortez tells Dems to go against Pelosi, defeat Senate border bill Replay More Videos ... MUST WATCH Ocasio-Cortez tells Dems to go against Pelosi, defeat Senate border bill 08:42

Prominent House Democratic progressives vocally denounced the House move to pass the Senate bill.

"A vote for Mitch McConnell's border bill is a vote to keep kids in cages and terrorize immigrant communities," Rep. Ilhan Omar tweeted on Thursday, writing, "How can we trust Donald Trump won't turn around and use this to fund his deportation plan or worse?"

"I do not believe we should be throwing more money to ICE," Rep. Alexandria Ocasio-Cortez of New York told CNN's Jake Tapper on "The Lead" Thursday after Pelosi's announcement. "My district is 50% immigrant. I have an obligation and responsibility to protect them. I believe what we should ideally be doing is passing a pure humanitarian bill to get money straight to the kids."

Rep. Pramila Jayapal, a co-chair of the progressive caucus, said on Thursday that Senate Democrats let this fight go.

Asked how exactly she would stop that from happening in future fights, she said, "I am looking for a new pharmaceutical drug that builds spines."

The Congressional Hispanic Caucus, which was actively involved in adding provisions to the House bill and wanted leadership to fight for those provisions in the Senate bill, released a statement on Thursday evening, saying, "We will not forget this betrayal."

The bill "will not stop the Trump Administration's chaos and cruelty," the statement said, adding, "As a result, migrants will continue to die."

This story has been updated with additional developments Thursday.