Republican congressional leaders have swung behind a hard-won agreement to prevent a new government shutdown and finance construction of more barriers on the Mexico border, selling it as a necessary compromise even as some on the right of the party voice opposition.

It is not clear whether President Donald Trump will support the deal, although party negotiators said they were hopeful.

Top Republicans Mitch McConnell in the Senate and Kevin McCarthy in the House both claimed victory, crowing about Democratic concessions on new border barriers and a late-stage battle over the ability of federal authorities to arrest and detain immigrants living illegally in the US.

“You’ve got to remember where Nancy Pelosi was. She has said, ‘No money for a wall’. That’s not the case,” Mr McCarthy said. “The Democrats have now agreed to more than 55 miles of new barrier.”

However, negotiators said it is pretty much the deal Mr Trump could have got in December.

Republicans and the White House were desperate to avoid another bruising shutdown. They tentatively agreed on Monday night to far less money for Mr Trump’s border wall than the White House’s 5.7 billion dollar (£4.4 billion) wish list, settling for a figure of nearly 1.4 billion dollars (£1.1 billion), according to congressional aides.

The huge funding measure, which combines seven spending bills into one, runs through the fiscal year, which ends on September 30.

Details might not be released until Wednesday but the pact came in time to alleviate any threat of a second partial government shutdown this weekend.

At the White House on Tuesday, spokesman Hogan Gidley was noncommittal: “We want to focus on what’s actually in the document. Until we see that, it’s going to be very difficult to have a conversation about what we will and won’t accept.”

The agreement means 55 miles of new fencing — constructed through existing designs such as metal slats instead of a concrete wall — but far less than the 215 miles the White House demanded in December.

The fencing would be built in the Rio Grande Valley in Texas. It closely mirrors Mr Trump’s original budget request from last winter.

The split-the-differences compromise contains plenty to anger legislators on the right and left — more 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 spectre of another shutdown this close, what brought us back together I thought tonight was we didn’t want that to happen,” said Senate Appropriations Committee chairman Richard Shelby.

Asked if Mr Trump would back the deal, the Republican 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 that “any Republican that supports this garbage compromise, you will have to explain”.