WASHINGTON — President Trump upended the Republican strategy to avert a shutdown early Thursday when he declared that an extension of a federal health insurance program for children “should be part of a long term solution” and not a stopgap spending plan.

That directly contradicts the thinking of congressional Republicans, who were eager to force Democrats to choose between a popular health care program they have pushed to renew for months and their effort to win legal protections for hundreds of thousands of young undocumented immigrants.

The House is scheduled to vote as soon as Thursday afternoon on the short-term spending bill with the health insurance program attached. Changing the bill could delay its consideration, further reducing the margin of error less than 48 hours before the shutdown deadline.

“CHIP should be part of a long term solution, not a 30 Day, or short term, extension!” Trump tweeted, using the acronym for the childhood health insurance program, known as the Children’s Health Insurance Program.

The White House on Wednesday issued a statement endorsing the short-term funding extension, including the health provision: “The Administration supports the bill’s multiyear funding extension of the Children’s Health Insurance Program.”

The prospects were equally dicey in the Senate, where several Democrats who had approved earlier short-term spending extensions announced Wednesday they would be voting “no” this time around. They were under intense pressure from immigrant activists to hold firm on demands for a solution for young immigrants known as “dreamers” who face losing protections against deportation yanked by the Trump administration.

“President Trump and the Republicans have a choice: they can either come to the table and negotiate in good faith on a responsible funding agreement and protection for DREAMers – or they can cause a government shutdown,” said Sen. Tom Udall, D-N.M., one of those Democrats.

In the House, Freedom Caucus Chairman Mark Meadows, R-N.C., left an evening meeting with Chief Deputy Whip Patrick T. McHenry, R-N.C., saying he had not been won over and that the short-term spending bill expected to come to the floor on Thursday remained short of votes.

“We’re making good progress, yet still at this point if the vote were to happen today there’s not the votes to fund it with Republican-only votes,” Meadows said. His group is pushing for greater defense spending, among other things.

The defections left the outlook uncertain, leaving open the possibility that the government will shut down Friday at midnight for the first time since 2013. Republican leaders in both chambers insisted that outcome would be avoided, and members of the House vote-counting team expressed guarded optimism that they’d be able to round up the necessary support in time for Thursday’s vote.

As negotiations continued on both ends of the Capitol, White House Chief of Staff John F. Kelly expressed optimism that Congress will work out a deal to protect dreamers.

Kelly gave an upbeat assessment of the state of play in the debate over legal status for immigrants brought to the United States illegally as children, while offering no timetable for when an agreement might be reached.

“The DACA deal will be worked out, I think, by the United States Congress,” Kelly told reporters on Capitol Hill. “Both sides of the aisle have agreed to meet in a smaller group and come up with [what] they think is the best DACA deal, and then it’ll of course be presented to the president.” DACA refers to the Deferred Action for Childhood Arrivals program.

Later, the White House expressed support for the one-month spending bill scheduled for a House vote Thursday, and congressional liaison Marc Short said he was optimistic it would pass. But at least one Republican – Sen. Lindsey O. Graham, R-S.C. – complicated the Republican outlook on the Senate side, saying he had informed leaders he will oppose the bill.

“I’m tired of it,” Graham told reporters. “This is the fourth one we’ve done, and you’re killing the military.”

Still, Senate Majority Leader Mitch McConnell, R-Ky., said there is a “good chance” the bill will pass in the upper chamber. “We’ll be taking that up as soon as it comes over from the House,” he said.

The bill would keep the government open through Feb. 16 while extending a popular children’s health program and rolling back several taxes in the Affordable Care Act. Many rank-and-file members grudgingly accepted the plan Wednesday.

“What other choice do we have this week?” asked Rep. Tom MacArthur, R-N.J. “I’m certainly not going to vote to shut the government down; that’s irresponsible.”

Meanwhile, Kelly conceded during a meeting with the Congressional Hispanic Caucus that there would be no “concrete wall from sea to shining sea” and no wall “that Mexico will pay for.” His comments were confirmed by four lawmakers and a senior aide who were present.

“Certain things are said during the campaign that are not fully informed,” Kelly said, according to the lawmakers and the aide.

“I had a lot to do with that,” Kelly said, adding that Trump “campaigned against DACA” but has “lightened up” since then.

“For right now, the first bite of the apple is to solve the DACA problem, issue, to have the border secured and [close] some of the loopholes,” Kelly told reporters. “And then the next step, as we’ve discussed in there, Phase 2, might be the larger issue of the 11 million people who have been here for years.”

The proposal of a short-term spending measure underscored Washington’s ongoing stalemate over the status of dreamers. Many Democrats are expected to oppose the bill in the absence of a deal to resolve the conflict.

“It doesn’t provide the necessary protection for the dreamers,” said Senate Minority Leader Charles E. Schumer, D-N.Y. “Democrats have been negotiating in good faith. . . . Instead, Republicans and the president seem intent on pursing a policy of intransigence.”

In the House, passing short-term spending legislation will require votes from the Freedom Caucus, whose members have sunk previous bills by withholding their support. The group has not officially opposed the measure, but several members said they want it to provide longer-term funding for the military.

If Republican leaders can quell dissent among deficit and defense hawks and pass the measure with only GOP votes, House Democrats will lose the leverage they planned to exercise on behalf of dreamers during the current round of negotiations.

Rep. Vicky Hartzler, R-Mo., a member of the House Armed Services Committee who wants to see a hike in defense spending, said it was “unconscionable” that military funding was being used as a political football by Democrats. But she suggested a shutdown would only play into their hands.

“They just care about scoring political points, and we’ve got to not let them do that,” she said.

Full-year military spending is a non-starter for Democrats who want a matching increase in nondefense spending. And absent a bipartisan budget agreement, the military spending levels Republicans favor would force across-the-board spending cuts under a 2011 budget law.

House Speaker Paul D. Ryan, R-Wis., laid the groundwork Wednesday for attacks on Democrats who vote against the funding plan, arguing that failing to pass the bill would hurt the military as well as beneficiaries of the Children’s Health Insurance Program, which the bill would extend for six years.

In the Senate, Minority Whip Richard J. Durbin, D-Ill., said Schumer is giving “lots of room” to members deciding how to vote on the short-term bill, including Democrats considered vulnerable in 2018.

In a meeting of Senate Democrats, Durbin said, “a handful stood up and said, ‘We’re going to vote against the CR.’ Another one or two said, ‘Not sure.’ No one stood up and said they had to vote for this thing.”