The House passed a spending bill that would pump up military funding and guarantee it though September, while leaving other agencies running on fumes through March 23.

That bill is a nonstarter in the Senate due to Democratic opposition. However, congressional leaders are nearing a bipartisan deal that would boost both defense and nondefense programs through 2019.

The Senate is expected to finalize that accord, pass it, and send it back to the House ahead of a Thursday midnight shutdown deadline.

Such a two-year deal to increase federal spending would clear a legislative roadblock that has kept Congress spinning its wheels for months.

Despite the optimism, no final agreement was in hand with less than three days until a Thursday midnight deadline, and even as congressional leaders were projecting optimism, President Trump was raising tensions by openly pondering a shutdown if Democrats did not agree to his immigration plan.

“I’d love to see a shutdown if we don’t get this stuff taken care of,” Trump said at a White House event focused on the crime threat posed by immigrants. “If we have to shut it down because the Democrats don’t want safety … let’s shut it down.”

Those comments came at the same time Senate Majority Leader Mitch McConnell, R-Kentucky, and Minority Leader Charles E. Schumer, D-New York, were telling reporters that a breakthrough was at hand – one that would deliver a defense spending boost Trump has long demanded as well as an increase in the nondefense programs championed by Democrats.

“We’re on the way to getting an agreement and on the way to getting an agreement very soon,” McConnell said. Schumer echoed the optimism moments later: “I am very hopeful that we can come to an agreement, an agreement very soon.”

Trump’s remarks, at least initially, appeared unlikely to snuff out the negotiations, which mainly involved lawmakers and their aides – not Trump and his White House deputies – and have largely steered clear of the explosive immigration issue.

White House press secretary Sarah Huckabee Sanders said Tuesday afternoon that Trump was not pushing for the inclusion of immigration policies in the budget accord – something that would upend the sensitive talks.

“I don’t think that we expect the budget deal to include specifics on the immigration reform,” she said. “But we want to get a deal on that.”

The deal to lift congressional spending caps through 2019 could be the only solution to a legislative puzzle that has already required four temporary spending bills to keep the government open since the fiscal year began on Oct. 1.

The House is set to vote Tuesday evening on a spending bill that would fund the military through September at boosted levels but leave other agencies running on fumes until March. That plan would be amended in the Senate, where Democrats are holding out for a matching increase in nondefense spending.

The agreement McConnell and Schumer are contemplating, with input from House Speaker Paul D. Ryan, R-Wisconsin, and House Minority Leader Nancy Pelosi, D-California, would clear the way for a bipartisan accord that would break through the sharp divides that helped prompt a three-day government shutdown last month.

“Democrats have made our position in these negotiations very clear,” Schumer said on the Senate floor Tuesday. “We support an increase in funding for our military and our middle class. The two are not mutually exclusive. We don’t want to do just one and leave the other behind.”

Among the issues that could be addressed in the deal is an increase in the federal debt limit, which could be reached as soon as early March, according to the Congressional Budget Office. Aides of both parties said that an increase was being discussed in the negotiations but that no final decisions have been made.

“It’s a question of what the traffic will bear,” said Sen. John Thune, R-South Dakota, the No. 3 Senate Republican leader, describing the likelihood of a debt-ceiling increase.

If the parties cannot reach an agreement in the next two days, it is unclear how a shutdown might be averted.

Multiple House Republicans said Tuesday that if the Senate takes their spending bill and strips out the increased military funding, they would have trouble voting for it. House Democrats, meanwhile, have showed only limited willingness to help pass temporary spending measures absent a broader agreement.

Rep. Barry Loudermilk, R-Georgia, said passing more-robust military funding is a “key element” for Republican lawmakers.

“We’ve got to do something to force them to actually do their jobs,” he said of senators. “I think it’s going to be tough if they send back something that doesn’t have the defense funding on it.”

Defense Secretary Jim Mattis told members of the House Armed Services Committee on Tuesday that Congress should “not let disagreements on domestic policy continue to hold our nation’s defense hostage.” He warned that a failure to pass long-term funding would imperil troop paychecks, inhibit the maintenance of planes and ships, stunt recruiting and otherwise harm military readiness.