On Wednesday night, a group of Republican and Democratic senators nailed down a difficult compromise on immigration that has been weeks in the making—a bill that provides a 12-year path to citizenship for young immigrants known as Dreamers, allocates the full $25 billion President Trump has demanded for the U.S.-Mexico border, bans the parents of DACA recipients from ever receiving citizenship, and bars legal permanent residents from sponsoring their adult, unmarried children.

But before the bill could even come to the floor for an expected vote Thursday, the Trump administration was working to undermine it.

At 1 a.m., the Department of Homeland Security released a hyperbolic screed against bill, saying it “destroys the ability of the men and women from the Department of Homeland Security (DHS) to remove millions of illegal aliens. It would be the end of immigration enforcement in America and only serve to draw millions more illegal aliens with no way to remove them.” The lengthy press release added that the bill “ignores the lessons of 9/11 and significantly increases the risk of crime and terrorism”—though the bill has no provisions at all regarding the student, business and tourist visas used by the perpetrators of 9/11—and said the bill “would effectively make the United States a Sanctuary Nation where ignoring the rule of law is encouraged.”

As Senate supporters of the compromise were working to whip up the 60 votes necessary to pass it Wednesday night, White House officials told the Washington Post they were doing the opposite—calling lawmakers and asking them to oppose it. In a sign the lobby effort may be working, two Republican senators who had participated in the bipartisan talks, Sens. James Lankford (R-OK) and Bob Corker (R-TN), announced Thursday they would oppose the compromise bill.

At noon on Thursday, the White House issued a formal threat to veto the bill.

“President Trump has shown a remarkable ability to snatch defeat from the jaws of victory,” fumed Senate Minority Leader Chuck Schumer (D-NY) Thursday morning about the White House veto threat. “Why? Because it isn’t 100 percent of what the president wants on immigration? That’s not how democracy works. You don’t get 100 percent of what you want in a democracy. Maybe in a dictatorship.”

Some Republicans also expressed alarm about the White House response to the compromise DACA bill. Sen. Lindsey Graham (R-SC), a cosponsor of the proposal, said Thursday that he’s “incredibly disappointed” in DHS for releasing such a “politicized” statement.

“It seems as if DHS is intent on acting less like a partner and more like an adversary,” he wrote. “Instead of offering thoughts and advice – or even constructive criticism – they are acting more like a political organization intent on poisoning the well. From the tone of this morning’s document, it appears as if DHS hopes all border security proposals fail. That would be the worst outcome of all.”

The White House is doubling down on its threat to veto any immigration bill other that the one modeled on President Trump’s outline, which includes the termination of the diversity visa lottery program and severe new restrictions on family immigration sponsorship for all U.S. citizens and green card holders.

The GOP bill that embodies Trump’s proposal is also slated for a Thursday vote, but it has almost no chance of getting 60 votes, with near-unanimous opposition from Democrats.

While the compromise bill has bipartisan support, many Democratic senators told reporters Wednesday that they are struggling to back it.

“There are a lot of things in it I have been against, like the $25 billion for the wall,” said Sen. Mazie Hirono (D-HI). “And I would have preferred the parents be protected. We have to find a way outside of this bill for the parents not to be deported. So, it’s going to be a huge compromise.”

But Hirono and other Democrats emphasized that the need to protect Dreamers, who will lose their work permits and be at risk of deportation on March 5 unless a federal court stops the Trump administration, is overriding many of their concerns.

“We need to get certainty for these kids, even if we have to make some tough compromises,” Sen. Heidi Heitkamp (D-ND) said after receiving a briefing about the new bill from Democratic leaders. “They said we’re going to have to vote our conscience, but they think this is the best that can be done in this short period of time.”

Heitkamp added that the very thing most enraging the Trump administration—that the bill does not slash legal family-based immigration across the board—is what is making it palatable to the Democrats whose votes are needed to pass it.

“Obviously a broader provision on family reunification is challenging,” she said. We can have that conversation when we go into comprehensive reform, but we won’t change it for every person just to advance the Dreamers.”

Though the bill appropriates the full $25 billion in border security funding the President demanded, the Trump administration is slamming the bill for not providing those funds upfront in a lump sum with no restrictions.

“The amendment ties the hands of all the men and women of DHS who stand at the border attempting to make our nation more secure,” DHS wrote.

“That’s just flat-out ridiculous,” Sen. Chris Coons (D-DE) said of the White House demands. “That’s asking Congress to completely hand over its responsibilities. This is as close to [the President’s plan] as you can get. It’s $25 billion pre-appropriated, subject to an annual plan from DHS, with provisions that make it very difficult for that money to be removed.”

Another bill up for a Thursday vote, drafted by Coons and Sen. John McCain (R-AZ), will likely get more Democratic votes but fewer Republican ones. That bill gives Dreamers a shorter pathway to citizenship—five years instead of 10-to-12—and doesn’t touch family reunification or diversity visas or the question of Dreamer parents.

As fear that the President’s opposition would kill the more conservative compromise bill’s chances of passage, scaring away potential Republican supporters, spread across Capitol Hill, Coons pleaded with his colleagues to ignore the White House’s bluster and vote for what they feel is right.

“The President has changed positions so many times on this issue,” he said. “I would urge them to consider this strong bipartisan bill that delivers on border security, that addresses family migration, that addresses the status of Dreamer parents. By demanding all four pillars and threatening a veto, the President is not being constructive. The Senate should be allowed to do this work.”