WASHINGTON — The House rejected the GOP’s compromise immigration measure Wednesday following weeks of negotiations and a last-minute endorsement from President Donald Trump.

Lawmakers overwhelmingly rejected the bill in a 121-301 vote, falling short of the roughly 218 votes needed to pass. No Democrats voted in favor of the bill.

While 121 Republicans voted in favor of the bill, 112 Republicans voted against it even after the president called on them to support the measure this morning. A number of those who opposed the legislation are members of the conservative Freedom Caucus.

At a press conference afterward, moderate Republicans blasted their colleagues for failing to pass the bill.

"A minority of Republicans joined every Democrat to vote for the status quo," said Rep. Carlos Curbelo, R-Fla. "They prefer petty politics of immigration instead of the solutions for immigration."

Moderates are committed, Curbelo said, to continue working with both sides of the aisle on immigration because he said that it's an issue that is "tearing our country apart."

This came just hours after Trump reversed course and urged House Republicans to back the legislation after telling them last week not to bother with it.

HOUSE REPUBLICANS SHOULD PASS THE STRONG BUT FAIR IMMIGRATION BILL, KNOWN AS GOODLATTE II, IN THEIR AFTERNOON VOTE TODAY, EVEN THOUGH THE DEMS WON’T LET IT PASS IN THE SENATE. PASSAGE WILL SHOW THAT WE WANT STRONG BORDERS & SECURITY WHILE THE DEMS WANT OPEN BORDERS = CRIME. WIN! — Donald J. Trump (@realDonaldTrump) June 27, 2018

Some Republican lawmakers had recently expressed concern that Trump had not weighed in on the legislation and said that its prospects for passage were uncertain without clear signs of support of the White House.

It was the first time that Trump publicly offered support for the legislation after telling House Republicans behind closed doors last week that he supported their immigration strategy "1000 percent" but not explicitly backing this measure. And then twice last week, the president appeared to sabotage House Republicans' efforts by suggesting that it was a waste of time to even vote on it because Senate Democrats would likely block the legislation anyway.

He also said last week that Republicans should wait to take action on immigration until after November’s midterm elections.

Trump's public backing of the legislation, however, may have been too late. House GOP leaders opted not to include two provisions a day earlier that conservatives had originally requested because they determined it would not alter the final vote tally.

The compromise bill would have provided nearly $25 billion in funding for Trump's border wall, limited legal and illegal immigration, provided protection from deportation and a path to citizenship for 1.8 million Dreamers, and keep undocumented families together who had crossed the border if the parents were facing prosecution.

Speaker Paul Ryan, R-Wis., said Tuesday that if the compromise bill fails, they would likely pursue a narrow bill to address the family separation issue at the border, but it’s unclear if the House would take that action before lawmakers leave Thursday for the July 4 recess next week.

The compromise bill stemmed from negotiations over the last month between moderate and conservative Republicans that also led to a vote on a more conservative immigration bill last week sponsored by House Judiciary Committee Bob Goodlatte, R-Va., that failed in a 193-231 vote.

Both groups began talking as a result of a discharge petition filed by moderates to force floor votes on immigration, which both conservatives and leadership opposed. The petition fell two signatures short of the 218 needed to force the votes on the floor on a range of proposals.