FILE - This Wednesday, Aug. 1, 2018, file photo shows the Capitol in Washington. As a potentially catastrophic hurricane heads for the Carolinas, Congress is moving to avert a legislative disaster that could lead to a partial government shutdown just weeks before the November midterm elections. (AP Photo/J. Scott Applewhite, File)

Congressional leaders from both parties have finalized a plan to avert a government shutdown at month’s end over President Trump’s demands to fund a border wall. Instead they will aim to postpone that fight until after the November midterm elections.

The bipartisan pact, announced on Thursday by Appropriations Committee Chairman Rodney Frelinghuysen (R-NJ), reflects the desire of Republican leaders to avoid a nasty shutdown fight weeks before the midterm elections — even if it means sacrificing, at least for now, one of Trump’s most prominent policy goals.

House GOP leadership aides say they believe the White House is on board with their approach, but no one can be sure what Trump ultimately will do. GOP leaders have been pushing Trump to back off rhetoric about shutting down the government, but he has vacillated, suggesting it could be good politics to force a shutdown Oct. 1 to try to get the money he wants for his wall.

While the announcement Thursday reduces the odds of a shutdown, midterm politics or the Freedom Caucus, a group of very conservative members allied with Trump, could always throw a curveball.

“The president will have to sign it into law or shut down the government,” Rep. Rosa L. DeLauro (D-Conn.) said at a meeting of a House-Senate Appropriations conference committee that signed off on the deal.

Government funding runs out on Sept 30. Congress is working to send Trump a number of must-pass spending bills for 2019 before then — including crucial measures funding the Pentagon and Health and Human Services Department. On Thursday, the House overwhelmingly passed a $147 billion three-bill package funding Veterans Affairs, military construction and numerous other programs, sending it to Trump for his signature.

But with only four legislative days left in the House before the Sept. 30 deadline, the rest of the spending bills that keep the government running will likely have to wait until after the election. That includes spending for the Homeland Security Department that pays for the wall.

Frelinghuysen announced those agencies will be funded on autopilot with a short-term spending bill lasting through Dec. 7. The so-called continuing resolution will be attached to a spending bill that includes huge funding increases for 2019 for the Pentagon — a major priority for Republicans and Trump — and big increases for the Health and Human Services Department, a Democratic goal.

This setup is aimed at greasing passage through the House and Senate — and allowing Trump to claim a win on the military funding.

Republicans insisted they still support funding the border wall as Trump wants, but that it doesn’t make sense to have a fight about it ahead of the midterm elections. The House Appropriations Committee has allocated $5 billion for the wall for 2019 — the figure Trump wants — but the Senate Appropriations Committee bill provides only $1.6 billion. Senate Democrats have shown no interest in going along with the higher number from the House, and Democrats have the ability to block spending bills which require bipartisan votes in the Senate. Trump long claimed that Mexico would pay for the wall.

“It doesn’t make a lot of sense to shut down the government and we’ll fight that fight when it comes, but this isn’t the time to have it,” said Rep. Tom Cole (R-Okla.), a senior member of the House Appropriations Committee. “I don’t presume to speak for the president but our leadership tells us that they’ve been in constant communication with the administration and that we’re proceeding on plan, so I assume that’s the case.”

The deal could also cement another setback for deficit hawks, because it would continue the Trump-era tradition of boosting up spending levels in the hopes of receiving bipartisan support. Trump had campaigned with a promise to cut spending, but he has consistently increased in since last year.

The plan to attach a continuing resolution and Health and Human Services spending to the Pentagon funding bill has angered conservatives in the House, some of whom are already announcing plans to oppose the measure.

“We’re using DOD as the leverage for every other bad fiscal decision,” said Rep. Mark Meadows (R-N.C.), chairman of the Freedom Caucus.

Although some conservatives, including Meadows, support the decision to delay a border wall funding fight, they are frustrated that many of their policy priorities got left out of the health, labor and education bill because they would not pass muster with Senate Democrats. These included provisions blocking funding for Planned Parenthood, for fetal tissue research and for administering the Affordable Care Act; and allowing federal funding for adoption agencies that do not want to work with same-sex couples.

But Democrats didn’t get everything they wanted either. Sen. Richard J. Durbin (D-Ill.) saw a bipartisan provision dropped that would have required disclosure of prescription drug prices in television ads. And Democrats failed to add a provision that would have barred use of a federal school grant program to buy guns. Education Secretary Betsy DeVos has said she will not stop districts if they choose to use their funding for firearms. In response, Democrats sought to clarify that such spending was not allowed, but Republicans said the provision wasn’t needed.