WASHINGTON — Lawmakers slogged toward completion of a massive spending bill and border security compromise Wednesday, preparing to pass it and send it to President Trump in time to prevent a government shutdown Friday at midnight.

The mood in the Capitol was less of enthusiasm than relief as negotiators finalized legislation that would end, for now, political brinkmanship over Trump’s demands for money for a southern border wall. Those demands produced the nation’s longest partial government shutdown before it ended late last month after 35 days.

The days of negotiations that followed produced a deal offering Trump less than a quarter of the $5.7 billion he wanted for barriers along the U.S.-Mexico border. Nevertheless, Trump is expected to sign the bill – although the president has changed his mind at the last minute before, creating a level of uncertainty.

Lawmakers were aiming to finalize the legislation late Wednesday, and votes were expected in the House and the Senate on Thursday. The bill is expected to pass. Trump said that he has to see the final deal before deciding whether he can support it, but he reiterated his insistence that regardless of what Congress does, the border wall will get built.

“We will get the job done. The wall is very, very on its way. It’s happening as we speak,” Trump said at an event with law enforcement officials.

“It’s a big wall. It’s a strong wall. It’s a wall that people aren’t going through very easy,” Trump said. “They would be able to climb Mount Everest easier.”

Despite Trump’s claims, the government has not completed any new sections of wall under his administration.

Earlier, addressing reporters at the White House, Trump repeated his suggestion that he will take some type of executive action to get additional money for the wall, saying, “We have options that most people don’t understand.” Republicans widely expect the president to try to move money from existing accounts, including one or more within the Pentagon budget, to add to the border barrier money appropriated by Congress, although Democrats say they will challenge such efforts.

Trump also said: “I don’t want to see a shutdown. A shutdown would be a terrible thing.”

A White House official told The Washington Post on Wednesday morning that President Trump sees signing the budget compromise legislation, if passed by Congress, as the way to avoid another shutdown. Administration officials say he would find a way to fund his border wall using funds allocated to other areas. Bloomberg photo by T.J. Kirkpatrick

Lawmakers grappled with a series of last-minute disputes Wednesday as they sought to finalize the deal, including an ultimately unsuccessful push by Democrats to include back pay for thousands of federal contractors who were caught up in the last shutdown, and – unlike the 800,000 affected federal workers – have not been able to recoup their lost wages. There was also a dispute over whether to include an extension of the Violence Against Women Act, which expires Friday. Ultimately, negotiators omitted an extension, but Democrats who are working on a stronger stand-alone bill argued there will now be a greater impetus to get it done and said the expiration will have little impact because grants under the law will continue.

FIFTY-FIVE MILES OF FENCE

The overall compromise, struck by a bipartisan group of lawmakers on Congress’s spending committees, includes $1.375 billion for 55 miles of new fences along the border in Texas, compared with $5.7 billion Trump had sought for 234 miles of steel walls. It contains language Democratic negotiators say should limit detention capacity by the U.S. Immigration and Customs Enforcement agency, although Republicans insist ICE will be able to maintain and even increase existing detention levels, and some liberals said Wednesday they oppose the legislation for that reason.

According to a document outlining some details of the deal, viewed by The Washington Post, the bill will provide $49.4 billion for the Homeland Security Department for the 2019 budget year, an increase of $1.7 billion above 2018 levels. The legislation also includes policy provisions specifying that members of Congress cannot be barred from accessing any facility housing children, and it contains language aimed at making it easier for separated children to reunite with family members in the U.S.

Combined spending on ICE and the Customs and Border Protection agency is around $23 billion, a figure Trump has begun touting to praise the legislation’s spending on border security.

The legislation wraps up Homeland Security spending with six other uncompleted appropriations bills for 2019, funding nine Cabinet departments and dozens of other agencies for a total price tag of around $324 billion. The other agencies covered include Commerce, Agriculture, Housing, State and the IRS, all of which would be funded through Sept. 30, the end of the fiscal year, presuming Trump signs the legislation. At that point, another fight over government funding – and, perhaps, the wall – will await.

Few lawmakers, even those who helped write it, had effusive praise for the package Wednesday. Instead, supporters described it as the best deal that could be achieved under the circumstances, and better than the alternatives: another government shutdown or a “continuing resolution” that would extend existing funding levels. House Democrats, in particular, argued against a continuing resolution because that approach would perpetuate spending agreements struck when Republicans controlled the House.

“We’re not asking anybody to hold their nose, and we’re not asking anybody to vote against their district,” said Rep. Pete Aguilar, D-Calif., one of the negotiators. “I think what we’re asking them to do is to weigh the competing interests of what’s in this bill versus also what would happen if this bill didn’t move forward and you had a continuing resolution. That’s not ideal either for our values.”

LIBERALS HOLD OUT

Some liberals said they would oppose the legislation, arguing there should be no money at all for new border barriers, and a stronger stand against the Trump administration’s aggressive immigrant detentions.

“We shouldn’t give him a penny for his wall. It was a political stunt,” said Rep. Juan Vargas, D-Calif. “It’s a total waste of money.”

Some Republicans were also unenthusiastic, but Majority Leader Mitch McConnell, R-Ky., argued on the Senate floor in favor of passing the legislation anyway.

“It goes without saying that neither side is getting everything it wants. That’s the way it goes in divided government,” McConnell said. “If the text of the bill reflects the principles agreed to on Monday, it won’t be a perfect deal – but it will be a good deal.”

For some conservatives, though, the deal represented an abandonment by Trump of his core campaign promise to build a wall along the U.S.-Mexico border, a wall he long claimed Mexico would pay for. Some conservatives said it was crucial for Trump to take whatever additional steps he could on his own to fulfill that promise to his base.

“If he signed the bill, based on what has been reported and suggested is in the bill, and did nothing else, it would be political suicide,” said Rep. Mark Meadows, R-N.C., a leader of the conservative House Freedom Caucus. “If he signed the bill, based on the way that we believe the bill to be, and takes other methods to obtain funding for additional border security measures, then I think there’s very little political liability from conservatives.”

OTHER MONEY FOR WALL

A U.S. defense official, speaking on the condition of anonymity because of the sensitivity of the discussions, said Tuesday night that the administration is considering drawing Defense Department money from several accounts, including some that support High Intensity Drug Trafficking Areas, a program created by Congress in 1988 to provide assistance to local jurisdictions with demonstrated drug problems.

It was unclear Wednesday how much Defense Department funding the White House wants to reallocate. The Pentagon’s 2019 budget includes $807.5 million for all of the U.S. military’s counterdrug efforts. The defense official predicted there will be some friction if money used for programs like the drug trafficking initiative are reallocated for other purposes.

“There is a finite amount of money available, and it is definitely going to affect someone’s operations,” the defense official said. “If you were planning for something and now it’s not there, that’s going to change what you can do.”

Democrats made clear they would object to efforts by the administration to reallocate funding appropriated by Congress, although some Republicans argued the administration could do so without congressional assent.

Aguilar said Democrats would call administration officials to testify on the Hill if they start moving money around in a way that violates the constitutional separation of powers.

“We’re going to respect Article One of the Constitution here and do our job, which is to make sure that we appropriate funding to these agencies, and if they don’t, they can expect to be up here quite a bit,” he said.