News of the agreement comes ahead of the potential government shutdown at the end of Thursday . Congress aims to avoid letting funding lapse for the second time in less than a month.

Another four-year extension of the Children's Health Insurance Program, for a total of a decade

While acknowledging that both sides had to make "painful" concessions to strike the deal, Senate Minority Leader Chuck Schumer called it a "win for the American people" and a "genuine breakthrough."

"This bill is a product of extensive negotiations among congressional leaders and the White House. No one would suggest it is perfect, but we worked hard to find common ground and stay focused on serving the American people," Senate Majority Leader Mitch McConnell said in announcing the agreement.

The two-year deal, which would increase current spending caps by roughly $300 billion , would include a major boost for military spending, with slightly smaller increases for domestic programs. It would also authorize funds for disaster aid, community health centers, the Children's Health Insurance Program and fighting the opioid crisis.

However, trouble brewed for the deal on both sides of the aisle on Wednesday. After McConnell and Schumer announced the agreement, it was unclear if it had enough support in the House.

House Speaker Paul Ryan said the U.S. "will be safer and stronger" because of the agreement and urged House members to back it.

White House press secretary Sarah Huckabee Sanders told reporters that President Donald Trump is happy with the direction of the budget deal. He took to Twitter to endorse it Wednesday evening.

@realDonaldTrump tweet

The deal will require Congress to pass a stopgap spending bill for only a few weeks while lawmakers write the two-year spending legislation.

After the House passed a short-term funding bill Tuesday night, the Senate appeared set to pass a separate version and send it back to the House. The conservative House Freedom Caucus has already indicated it will not support the spending increases.

House Republicans were meeting Wednesday afternoon as the Senate leaders announced the deal.

House Minority Leader Nancy Pelosi, D-Calif., also said she would support the emerging spending deal only if Ryan gives assurances about an open debate on immigration legislation. That puts pressure on Republicans, who could still pass a bill in the House even if nearly all Democrats voted against it.

Democrats previously wanted to pass a bill protecting hundreds of thousands of young immigrants from deportation in tandem with legislation to raise budget caps. Schumer relented on that point after McConnell agreed to an open debate on immigration bill starting next week.

On Wednesday, McConnell said he would start the immigration legislation process without a set bill and allow a "fair" amendment process.

"While I obviously cannot guarantee any outcome, let alone supermajority of support, I can ensure the process is fair to all sides. And that is what I intend to do," he said.

Schumer urged Ryan to "allow a fair and open process" on an immigration bill.

Republicans want at least some border security measures passed along with protections for the immigrants. Trump and conservatives seek restrictions on legal immigration that Democrats are unlikely to support.

On Tuesday, Trump injected uncertainty into the funding debate when he said he would "love" to see a shutdown if Democrats do not back his immigration demands. The White House later said the president did not want to see a shutdown and did not expect to see specific immigration proposals included in a spending bill this week.

Schumer said congressional leaders struck the deal "without a great deal of help from the White House."

He added: "While President Trump threatens shutdowns and stalemates, congressional leaders have done the hard work of finding compromise and consensus."