President Trump speaks at an event at the White House complex Friday with “angel families,” the term used by the administration for families affected by crimes committed by immigrants in the country illegally. (Jabin Botsford/The Washington Post)

The House on Wednesday soundly rejected a wide-ranging GOP immigration bill that would have funded President Trump’s border wall, offered young undocumented immigrants a path to citizenship and partially addressed the family-separation crisis at the southwest border.

The bill failed on a vote of 301 to 121 despite a last-minute tweet — in all-capital letters — of support from Trump, the backing of GOP leadership and weeks of negotiations between conservatives and moderate Republicans who sought an elusive intraparty compromise.

But the GOP has been unable to bridge the divide between hard-liners aligned with Trump and moderates intent on addressing the fate of immigrants known as “dreamers.”

Highlighting the GOP’s failure to achieve consensus on any immigration-related legislation, Republican aides said the House would not vote this week on a narrower measure aimed squarely at the separation policy, thanks to disputes between Congress and the White House on how far such a bill should go.

Lawmakers will leave for a 10-day Fourth of July recess taking no action amid an uproar over the separation policy and images of migrant children housed in metal cages.

Republican leaders struggled to rally support for the broader bill, postponing a vote twice in the face of internal opposition and uncertain support from Trump. No Democrat supported the bill, which in addition to funding the border wall rolled back legal immigration pathways favored by most Democrats.

The 11th-hour tweet from Trump urged lawmakers to “SHOW THAT WE WANT STRONG BORDERS & SECURITY” by passing the bill. That message stood in stark contrast to a tweet he sent Friday in which he said Republicans “should stop wasting their time” on immigration until after the midterm elections, when, he predicted, more GOP lawmakers would be elected.

Nearly half of the House Republicans voting Wednesday ultimately brushed off Trump’s entreaty, and several said afterward that they did not feel as though they had spurned the president.

“I was looking at my district and things I wanted to have in [the bill] from Day 1,” said Rep. Roger Williams (R-Tex.). “We need to start securing the border, and not reward bad behavior, and that’s what this bill did.”

Rep. Warren Davidson (R-Ohio), a member of the hard-right Freedom Caucus, suggested that GOP leaders instead try to build support for a more conservative alternative that failed with 193 votes last week.

“The reality is, the [immigration bill] we voted on last week was already a compromise,” he said. “And this bill that we voted on just now was a compromise. Which compromise came closer to crossing the threshold?”

GOP lawmakers spent more than month embroiled in an extended debate about a divisive issue that House leaders had hoped to avoid in an election year. Court decisions have held up Trump’s cancellation of the Deferred Action for Childhood Arrivals program, or DACA, which has protected hundreds of thousands of dreamers from deportation. Those court rulings also sapped any urgency in Congress to act.

But a cadre of Republican moderates, frustrated by the inaction, moved in May to force votes on bills, including bipartisan measures favored by most Democrats. GOP leaders scrambled to avoid the possibility of a Republican-led House passing a relatively liberal immigration bill by convening negotiations on a GOP-written alternative.

The resulting legislation largely followed immigration principles issued by the White House in January, providing $25 billion for Trump’s long-sought border wall, scaling back legal immigration and giving young immigrants in the country illegally a shot at citizenship. It also would have allowed migrant families to remain together in detention.

After Wednesday’s vote, several moderates said it had proven that only bipartisan legislation had any hopes of passing the House.

“There are a number of Republicans who will never get to yes, and certainly there are Democrats who are willing to work with us to find a real solution,” said Rep. Jeff Denham (R-Calif.).

Leaders of the bloc said they were considering whether to try again to force action through a “discharge” petition, acknowledging that it would be difficult. A previous petition fell two Republican signatures short, and to force votes before the midterms, they would have to convince 218 House members to sign by July 9.

Denham said some Republicans who held off on signing the earlier petition might now change their minds: “They were convinced that we could find a Republican solution. It was obvious today that there was no Republican solution.”

Before Wednesday’s tweet, many Republicans had complained that Trump had not been emphatic enough in his support for the bill. The House rejected a more conservative immigration bill last week after Trump visited Capitol Hill in a bid to get at least one of the two bills through the chamber. But lawmakers felt that Trump has not explicitly called on them to pass the compromise measure, leaving them free to vote only for the more conservative alternative.

Still, House lawmakers negotiated through the weekend trying to figure out whether they could add components to the bill that would get it closer to passage.

GOP leaders filed a 116-page amendment Monday night that would expand temporary visas for agricultural workers while also requiring all employers to screen their workers for legal status using the federal E-Verify database.

But conservatives continued to balk at other aspects of the bill, including its central appeal to moderates: a clear pathway to citizenship for the roughly 1.8 million young immigrants in the country illegally after arriving in the United States as children.

To many conservatives who weighed in on the bill Tuesday, that represented an amnesty that they said would serve only to encourage future illegal immigration. That position has infuriated moderates, who spent weeks at the negotiating table, handing concessions to conservatives to secure their support.

On Tuesday evening, House leaders decided to abandon their latest amendment and go forward Wednesday with a vote on a bill that they expected to fail. Trump’s tweet the next morning, GOP aides said, could not change the outcome.

“Too little, too late,” said one, speaking on the condition of anonymity to be candid.