A sprawling, compromise GOP immigration bill that would have provided a path to citizenship for young illegal immigrants while directing $25 billion for the construction of President Trump’s border wall failed in the House on Wednesday, despite encouragement from the president for Republicans to support it.

The bill was overwhelmingly rejected 301-121, in part because some Republicans are reluctant to vote for any bill they worry could be portrayed as “amnesty.”

More than 100 Republicans voted against the legislation.

Earlier Wednesday, the president called for Republicans to pass the “strong but fair immigration bill,” saying that “passage will show that we want strong borders & security while the Dems want open borders.”

PROPOSED DACA PATHWAY COMPLICATES BORDER WALL FUNDING

After months of trying to bridge the chasm between moderates and conservatives and two postponed votes, House Speaker Paul Ryan, R-Wis., labeled the legislation "a great consensus bill" and tried putting the best face on the likely outcome.

"What we have here is the seeds of consensus that will be gotten to, hopefully now but if not, later," he told reporters Tuesday.

But on Friday, Trump initially suggested he was giving up trying to get a bill approved before the election, saying a "red wave" is needed to pass an immigration bill in Congress.

“Republicans should stop wasting their time on Immigration until after we elect more Senators and Congressmen/women in November,” Trump tweeted. “Dems are just playing games, have no intention of doing anything to solves this decades old problem. We can pass great legislation after the Red Wave!”

Wednesday's vote caps months of futile GOP efforts to pass wide-ranging legislation on an issue that could color scores of congressional races in this fall's contest for House and perhaps Senate control. The Senate rejected three proposals in February, including one reflecting Trump's hardline policies and two bipartisan plans.

The Republican compromise voted on Wednesday would have provided a shot at citizenship for hundreds of thousands of immigrants brought illegally to the U.S. as children. It would provide $25 billion for Trump to build his coveted wall with Mexico, restrict family-based immigration and bar the Homeland Security Department from taking migrant children from parents seized crossing into the country without authorization.

Leaders had been adding eleventh-hour provisions aimed at winning votes. One would make it easier for migrant farmworkers to stay longer in the country, the other would gradually require companies to use an electronic database to verify their employees' U.S. citizenship.

But those amendments didn't remove the key stumbling block -- the reluctance by conservatives to back legislation helping people who arrived illegally become citizens. Many Republicans deride that plan as amnesty for lawbreakers, a potential attack line their next primary challenger could wield against them.

Fox News’ Chad Pergram and Adam Shaw and The Associated Press contributed to this report.