WASHINGTON (AP) — Congressional negotiators reached agreement to prevent a government shutdown and finance construction of new barriers along the U.S.-Mexico border, overcoming a late-stage hang-up over immigration enforcement issues that had threatened to scuttle the talks.

Republicans were desperate to avoid another bruising shutdown. They tentatively agreed Monday night to far less money for President Donald Trump’s border wall than the White House’s $5.7 billion wish list, settling for a figure of nearly $1.4 billion, according to congressional aides. The funding measure is through the fiscal year, which ends on Sept. 30.

ADVERTISEMENT

It’s not clear whether Trump will support the deal, although GOP negotiators said they were hopeful.

The agreement means 55 miles (88 kilometers) of new fencing — constructed through existing designs such as metal slats instead of a concrete wall — but far less than the 215 miles (345 kilometers) the White House demanded in December. The fencing would be built in the Rio Grande Valley in Texas. It actually closely mirrors Trump’s original budget request from last winter, however.

The split-the-differences compromise contains plenty to anger lawmakers on the right and left — too much border fencing than many Democrats would like and too little for conservative Republicans — but its authors praised it as a genuine compromise that would keep the government open and allow everyone to move on.

“With the government being shut down, the specter of another shutdown this close, what brought us back together I thought tonight was we didn’t want that to happen” again, said Senate Appropriations Committee Chairman Richard Shelby, R-Ala.

Details won’t be officially released until Tuesday, but the pact came in time to alleviate any threat of a second partial government shutdown this weekend. Negotiators said it’s pretty much the deal that Trump could have gotten in December. Aides revealed the details under condition of anonymity because the agreement is tentative.

“Our staffs are just working out the details,” said House Appropriations Committee Chairwoman Nita Lowey, D-N.Y. She said the huge measure — which combines seven spending bills into one — measure would be publicly released as early as Tuesday afternoon.

The pact also includes increases for new technologies such as advanced screening at border entry points, humanitarian aid sought by Democrats, and additional customs officers.

This weekend, Shelby pulled the plug on the talks over Democratic demands to limit immigrant detentions by federal authorities, frustrating some of his fellow negotiators, but Democrats yielded ground on that issue in a fresh round of talks on Monday.

Asked if Trump would back the deal, Shelby said: “We believe from our dealings with them and the latitude they’ve given us, they will support it. We certainly hope so.”

But Fox News Channel’s Sean Hannity, a Trump ally, said the barrier money in the agreement was inadequate. He warned late Monday that “any Republican that supports this garbage compromise, you will have to explain.”

“I would hope that Sean Hannity and all the other people you mentioned aren’t running this government. This was a bipartisan deal, Senate and House, Republican and Democrat,” top negotiator Rep. Nita Lowey, D-N.Y., said on CNN. “When we sat around the table and negotiated this deal, we didn’t call Sean Hannity, we didn’t call (Ann) Coulter.” Coulter is a conservative commentator.

Trump traveled to El Paso, Texas, for a campaign-style rally Monday night focused on immigration and border issues. He has been adamant that Congress approve money for a wall along the Mexican border, though he no longer repeats his 2016 mantra that Mexico will pay for it, and he took to the stage as lawmakers back in Washington were announcing their breakthrough.

“They said that progress is being made with this committee,” Trump told his audience, referring to the congressional bargainers. “Just so you know, we’re building the wall anyway.”

Democrats carried more leverage into the talks after besting Trump on the 35-day shutdown but showed flexibility in hopes on winning Trump’s signature. After yielding on border barriers, Democrats focused on reducing funding for detention beds to curb what they see as unnecessarily harsh enforcement by Immigration and Customs Enforcement, or ICE.

The agreement yielded curbed funding, overall, for ICE detention beds, which Democrats promised would mean the agency would hold fewer detainees than the roughly 49,000 detainees held on Feb. 10, the most recent date for which figures were available. Democrats claimed the number of beds would be ratcheted down to 40,520.

But a proposal to cap at 16,500 the number of detainees caught in areas away from the border — a limit Democrats say was aimed at preventing overreach by the agency — ran into its own Republican wall.

Democrats dropped the demand in the Monday round of talks, and the mood in the Capitol improved markedly.

Trump met Monday afternoon with top advisers in the Oval Office to discuss the negotiations. He softened his rhetoric on the wall but ratcheted it up when alluding to the detention beds issue.

“We can call it anything. We’ll call it barriers, we’ll call it whatever they want,” Trump said. “But now it turns out not only don’t they want to give us money for a wall, they don’t want to give us the space to detain murderers, criminals, drug dealers, human smugglers.”

The recent shutdown left more than 800,000 government workers without paychecks, forced postponement of the State of the Union address and sent Trump’s poll numbers tumbling. As support in his own party began to splinter, Trump surrendered after the shutdown hit 35 days, agreeing to the current temporary reopening without getting money for the wall.

The president’s supporters have suggested that Trump could use executive powers to divert money from the federal budget for wall construction, though he could face challenges in Congress or the courts.

The negotiations hit a rough patch Sunday amid a dispute over curbing ICE, the federal agency that Republicans see as an emblem of tough immigration policies and Democrats accuse of often going too far.

The border debate got most of the attention, but it’s just part of a major spending measure to fund a bevy of Cabinet departments. A collapse of the negotiations would have imperiled another upcoming round of budget talks that are required to prevent steep spending cuts to the Pentagon and domestic agencies.

___

Associated Press writers Catherine Lucey and Lisa Mascaro in Washington and Jill Colvin in El Paso, Texas, contributed to this report.