The House passed the Senate version of a $4.6 billion border-funding bill that would partially aid the migrant detention centers mired in poor conditions and controversy.

The bill first passed the Senate in an overwhelmingly bipartisan vote. But House Democrats wanted to set up their own legislation.

But House Speaker Nancy Pelosi caved after moderate Democrats demanded they just take up the Senate bill and the White House refused to budge.

Progressives were considerably angry. Rep. Alexandria Ocasio-Cortez of New York went on a Twitter tirade against Senate Majority Leader Mitch McConnell on Thursday.

Visit Business Insider's homepage for more stories.

WASHINGTON — The House of Representatives passed a $4.6 billion emergency funding bill for border security and better conditions at migrant detention centers on Thursday. The bill, first passed by the Senate in an overwhelmingly bipartisan fashion, is now slated to go to President Donald Trump's desk for his signature.

The passage of the bill is the culmination of a major failure from House Speaker Nancy Pelosi. The original House version of the border-funding bill went down in flames in the Senate. When Pelosi and progressives in the House wanted to hash out the differences with the Senate, a rebellious group of moderates forced her hand to simply take up the Senate vote.

The bill passed the House in a 305-102 vote, with 26 members not voting.

Read more: Mitch McConnell won't cancel crucial Senate votes, even with 7 Democrats out of town for the presidential debates

The Senate bill, which passed the upper chamber in an 84-8 vote, contains funding for law enforcement, including $145 million for military operations along the border. The bulk of the supplemental legislation goes toward helping migrants and detention facilities, with $2.88 billion for the Department of Health and Human Services and $1.1 billion for Customs and Border Protection for processing.

"They pass their bill, we respect that," Pelosi said on Wednesday. "We passed our bill, we hope they would respect that. And there are some improvements that we think can be reconciled."

Pelosi then found herself at the center of a major ideological rift within the House Democratic Caucus.

Progressive House Democrats closer to the party's base wanted stricter enforcement of the allocated funds to ensure they were going only toward improving conditions for the countless migrants at detention facilities across the US.

The demand for taking the House and Senate versions to a conference stemmed from many progressives distrusting the White House to follow through and not use funds for border security and enforcement.

Progressives were considerably angry. Rep. Alexandria Ocasio-Cortez of New York went on a Twitter tirade against Senate Majority Leader Mitch McConnell on Thursday.

"His Senate bill is a militarization bill. McConnell killed the House Bill & dropped this one right before recess to force passage," she wrote. "Well, too bad. This is our job. Cancel vacation, fly the Senate in. Pass a clean humanitarian bill & stop trying to squeeze crises for more pain."

But McConnell did not "kill" the House bill. He brought it up for a vote, which failed 37-55, as lawmakers in the upper chamber preferred their version, authored by Democratic Sen. Patrick Leahy of Vermont and Republican Sen. Richard Shelby of Alabama.

Read more: Trump hits back at reports questioning significance of Mexico deal

A group of moderate lawmakers, the Problem Solvers Caucus, told the House to just take up the Senate bill before Congress recesses for the Independence Day break. Other moderates joined in, demanding that something had to be done and ready for Trump to sign by the end of the week.

Pelosi also spoke with Vice President Mike Pence, according to one aide, and he reiterated the administration's commitment to the Senate version.

From there, it became apparent the Senate bill was the only way forward.

Before the vote on Thursday, Pelosi sent a letter to Democratic colleagues, saying she was "gravely disappointed in the actions taken by the Senate in opposing regular order of Congress" but adding that the bill had to be passed.

"In order to get resources to the children fastest, we will reluctantly pass the Senate bill," she wrote. "As we pass the Senate bill, we will do so with a Battle Cry as to how we go forward to protect children in a way that truly honors their dignity and worth."