WASHINGTON - The Senate prepared Wednesday to pass a short-term spending bill that would keep the government open through the New Year but deny President Trump the money he wanted for his border wall - a stark retreat for Republicans in their final days in control of Congress.

Majority Leader Mitch McConnell, R-Ky., announced the deal on the Senate floor Wednesday to extend government funding through Feb. 8, when Democrats will be in control of the House. Minority Leader Charles Schumer, D-N.Y., said Democrats would support it.

The outcome would temporarily break an impasse that threatened to shutter large portions of the government this weekend and send hundreds of thousands of federal workers home without pay just before Christmas.

Trump has signaled his support for the plan but "can change his mind if he wants to," said Sen. John Cornyn, R-Texas, the No. 2 Senate Republican. A senior White House aide, speaking on the condition of anonymity to discuss the administration's position, said the plan is for Trump to sign the legislation McConnell is introducing.

That would represent a major defeat for Trump on his signature issue, the U.S.-Mexico border wall he long insisted Mexico would pay for but has demanded $5 billion in taxpayer money to fund. And it's an abandonment of his stance from a week ago, when he claimed he would be "proud" to shut down the government to get his wall money.

Trump has oftened changed his mind or threatened to veto bills at the last minute, so a shutdown is still possible.

Trump continued to assert over Twitter on Wednesday that the wall would be built, insisting Mexico would pay for it via the renegotiated North America trade deal and that the military would build it.

The legality of such an approach is in question, and Schumer insisted Democrats would not let it happen. It's also unclear how the trade deal would mean Mexico is paying for the wall.

McConnell blamed the outcome on Democrats after they turned down a GOP offer on Tuesday that would have provided $1.6 billion for border barriers and another $1 billion for Trump to spend on other immigration priorities.

"Faced with this intransigence - with Democrats' failure to take our borders seriously - Republicans will continue to fulfill our duty to govern," McConnell said. "That's why we will soon take up a simple measure that will continue government funding into February: So we can continue this vital debate after the new Congress has convened."

Schumer spoke on the floor shortly thereafter, saying: "I'm glad the leader thinks the government should not shut down over the president's demands for a wall, and Democrats will support this CR." A CR is a "continuing resolution" extending government funding.

The Senate could pass the measure as soon as Wednesday and the House by Thursday, marking a humbling end to the 115th Congress and two years of unified GOP control of Washington. About 25 percent of government funding would run out at the end of Friday absent action by Congress and Trump.

"One way or the other, we will win on the Wall!" Trump said in a morning tweet. In another, he sought to make the case that because of "large scale criminal and drug inflow" the military would be justified in building a border wall.

Just last week, Trump told Democratic congressional leaders that he'd be "proud" to shut down the government to get his wall money. But in recent days, Democrats have held firm against his demand, and Republicans have appeared increasingly eager to avoid a partial shutdown heading into the Christmas holiday.

During a television appearance before McConnell's announcement Wednesday morning, White House counselor Kellyanne Conway insisted Trump had not softened his stance on the wall but said the White House wanted to see what Congress would produce.

"The president has said he's willing to do what he has to do to get that border security, including a government shutdown," she said on Fox News's "Fox & Friends." "Now we'll see what the Senate and the House, what they come together and present to the president. We don't know what's going to make it to his desk."

She said that while Congress had worked successfully with Trump on other issues, lawmakers seemed to be "walking away" on border security.

She also reiterated the White House's view that it could redirect money from other areas, a strategy that has limits given congressional powers over appropriations.

"There are other ways for him to get that money," Conway said. "He's not going to back down."

Multiple budget experts said it would be illegal for Trump to take money from the Pentagon and redirect it toward the construction of a wall. At a minimum, such a change would require the approval of at least four congressional committees, two of which will be controlled by Democrats in two weeks.

"If Congress did not appropriate money to build a wall, you cannot just use other unrelated appropriations to do that," said Todd Harrison, director of defense budget analysis at the Center for Strategic and International Studies.

Schumer said Democrats would not allow it to happen.

"Let me be very clear. The administration cannot reprogram funds appropriated by Congress for the full wall without our assent," Schumer said on the Senate floor. "To do so would violate Congress' Article One powers. They cannot do it on their own and the House and Senate will not approve a wall from reprogrammed funds or anything else. It won't happen."

If Trump did order the military to build a wall anyway, Democrats or landowners could file a lawsuit and seek an immediate injunction to halt the construction. Trump has also not disclosed how he plans to deal with all the private property that runs along the border in Texas. If he orders the military to effectively seize that land through eminent domain it would open a host of additional legal issues.

Congress passed a spending bill for military programs that runs through September 2019, giving the White House even less flexibility in reappropriating existing funds. But White House officials have been scouring the budget rules for weeks and could try to combine a number of unrelated programs in a way that helps with the construction of a barrier. They haven't specified how they would do that though.

Congress has passed several spending bills in the past year that allowed the administration to repair and rebuild existing portions of border walls and even add some new barriers, but these projects have fallen far short of the scope Trump sought during the campaign.

A partial government shutdown would be the third this year, after Congress's terminal budget dysfunction forced two brief shutdowns in January and February before lawmakers managed to get their spending bills back on track. But that effort was derailed again in recent fighting over the border, as Trump demanded taxpayer funds for a wall he had long claimed Mexico would pay for.

In one of his tweets Wednesday, Trump again asserted that Mexico would be paying for the wall "indirectly" through a pending trade deal with Canada and Mexico - a concept his advisers have struggled to explain.

White House press secretary Sarah Sanders said Tuesday that funding would come from new revenue to the Treasury Department triggered by economic growth, but this would be very hard to measure with any precision, if at all.

House Majority Whip Steve Scalise (R-La.) said on Fox News Wednesday that Trump could use his State of the Union address late in January to make his case for the wall, as well as to hammer Democrats for blocking funding for it.

"If the negotiation is going to go until February, one of the good things about that is the State of the Union will be right before that next funding resolution, which means the president has a real good opportunity to go to the country, make a case at the State of the Union for why Nancy Pelosi and Chuck Schumer are on the wrong side of this issue, not wanting to keep our country safe, while the president is fighting to build the wall," Scalise said.

The Washington Post’s Josh Dawsey and Seung Min Kim contributed to this report.