The House passed a short-term spending bill Tuesday that would avert a government shutdown Friday, setting up a December showdown over President Trump’s border wall that could fall in the midst of impeachment votes against the president.

The legislation, which passed 231 to 192, extends government funding through Dec. 20. It must pass the Senate and be signed by Trump before midnight Thursday. If not, government funding would expire, causing many agencies to begin to shutter operations and furlough staff.

The Senate is expected to act on the legislation ahead of the deadline. A senior administration official said Tuesday that Trump is expected to sign the bill. The official spoke on the condition of anonymity to avoid speaking publicly ahead of an official announcement.

Passage of the “continuing resolution” was necessary because lawmakers and the administration have failed to agree on full-year spending bills for the 2020 budget year that began Oct. 1. The government is operating on a stop-gap spending bill that was passed in September but expires Thursday night.

Ahead of the vote, lawmakers of both parties bemoaned their failure to agree on the 12 annual spending bills for 2020, and the resulting need to enact short-term measures once again.

“This is an admission of failure, it’s a recognition of failure,” said Majority Leader Steny H. Hoyer (D-Md.). But, Hoyer added, “The alternative is shutting down government on midnight of the 21st. That’s not an acceptable alternative.”

Trump’s demands for billions of dollars to construct a wall along the U.S.-Mexico border have again emerged as the principal impediment to a broader budget deal. Trump wants $5 billion for the wall, and Senate Republicans signed off on that figure earlier this year. But House Democrats dedicated no money at all to the wall in spending bills they passed. It remains unclear how — or if — a compromise can be struck.

That makes a government shutdown a real threat when the new funding bill expires Dec. 20, just before Christmas and potentially around the very same time the House is voting on articles of impeachment against Trump.

“We have to work out something with the Democrats on the wall, and things maybe related to the wall,” said Senate Appropriations Chairman Richard C. Shelby (R-Ala.). He said that thus far, he’s seen no willingness to compromise on the part of the White House or House Democrats.

And in an ominous sign of increased partisanship around the spending process, only 12 House Republicans voted in favor of the short-term spending bill Tuesday -- many fewer than the 76 Republicans who supported the last stop-gap bill. House Republicans voiced various complaints, accusing Democrats of failing to work in good faith on striking a larger budget deal. Democrats, for their part, contended that Senate Republicans and the White House were to blame.

During a closed-door House Democratic caucus meeting Tuesday, Speaker Nancy Pelosi (D-Calif.) sounded pessimistic about prospects for a deal ahead of the Dec. 20 deadline, according to a Democrat in the meeting who spoke on the condition of anonymity to talk about the private discussion.

The dispute over the border wall caused a 35-day government shutdown last winter. It ended without Congress giving Trump all the money he wanted for the wall. Ultimately, over bipartisan objections from Congress, Trump declared a national emergency at the border that the White House used to take billions from military construction accounts and direct the money to the wall.

The White House has made clear that if Congress does not approve all the money Trump wants for the wall this time around, he will once again circumvent Congress to pull money from other accounts and direct it to the border.

Despite the dispute over the wall, House Appropriations Committee Chairwoman Nita M. Lowey (D-N.Y.) said it was imperative for Congress to reach a deal to fully fund the government through the 2020 budget year that ends Sept. 30, 2020. If they don’t, budgets for government agencies including the Pentagon, the Department of Health and Human Services and numerous other accounts would continue at current levels. That would mean missing out on billions of dollars in spending increases for the Pentagon and domestic agencies previously agreed to by Congress — an outcome lawmakers of both parties want to avoid.

“It is absolutely essential that we get our work done,” Lowey said.

The “continuing resolution” passed Tuesday also includes a number of other provisions, including a 3.1 percent pay increase for members of the military. It allocates money for the census. And the legislation extends into March provisions of the USA Patriot Act that were set to expire Dec. 15, including one called Section 215 that allows the government to collect records from telephone companies and other entities related to counterterrorism investigations. Some lawmakers oppose this extension because of concerns that data can be collected on private citizens.