US senate leaders said on Wednesday they had reached a bipartisan budget deal for 2018 and 2019 - a move which, if approved by Congress, would avert a second government shutdown in just three weeks.
The deal, months in the making, was seen as a major achievement for both the ruling Republicans and opposition Democrats in a deeply divided Washington.
The breakthrough came on the eve of a midnight Thursday deadline for Congress to pass a stopgap spending measure - its fifth since October - or once again turn the lights out on the federal government.
The proposal would lift caps on federal spending that were mandated under a 2011 law, boosting military and non-military funding by some $300 billion in total, aides said.
"The compromise we've reached will ensure that, for the first time in years, our armed forces will have more of the resources they need to keep America safe," Senate Majority Leader Mitch McConnell said on the Senate floor.
Republican Senator Lindsey Graham, a defense hawk, said it was the "best news for the military... since 2011."
The agreement would also ensure funding for domestic priorities pushed by Democrats including disaster relief, health centers and fighting a surging opioid epidemic.
"The budget deal doesn't have everything Democrats want, it doesn't have everything the Republicans want, but it has a great deal of what the American people want," top Senate Democrat Chuck Schumer told his colleagues.
The deal raises the debt ceiling until March 2019, postponing a potential fiery clash within President Donald Trump's own Republican Party, and essentially clears the decks for Congress to address other thorny issues such as immigration and infrastructure.
Before the deal was announced, the House passed a partisan bill that would fund government for six weeks and the military through the remainder of fiscal year 2018.
The Senate is now expected to rewrite that measure, pass it and send it back for House approval before Thursday's funding deadline - provided there are no efforts to slow the process in the Senate.
Mr McConnell and Mr Schumer said the deal was the product of extensive negotiations between both parties and the White House, which reacted positively to developments on Capitol Hill.
______________
Read more:
Senate leaders reach $300 billion federal spending deal
Dollar steady as euro feels squeeze
_______________
"We're certainly happy with the direction that it's moving," press secretary Sarah Sanders said, adding that the White House would need to see the final components.
That was a turnaround from Tuesday, when Mr Trump had said he would "love" a shutdown if he did not get his way on immigration.
Several Senate Democrats, including John Tester of Montana, said they were buoyed by the deal but wanted to study the details before signing on.
House Speaker Paul Ryan said the deal breaks the "logjam" on public priorities and makes America "safer and stronger," and urged all House members to support it.
But the compromise could face stiff blowback in the lower chamber of Congress, where fiscal conservatives may balk at adding $300 billion to the national debt just months after passing a $1.5 trillion tax cut package.
But liberal stalwarts might also revolt, over the sensitive issue of immigration and the fate of millions of undocumented migrants.
Immigration is not part of the compromise. Instead, McConnell will allow an open debate on possible immigration solutions on the Senate floor, beginning as early as next week - a promise he made to end a three-day shutdown last month.
Democrats have long pursued a strategy to link the federal funding debate to a solution for hundreds of thousands of "Dreamer" immigrants who were brought to the country illegally as children.
Top House Democrat Nancy Pelosi highlighted the approach Wednesday with an extraordinary day-long address to her House colleagues in which she read dozens of testimonials from "Dreamers" and called on Ryan to take action on immigration.
The Dreamers were shielded from deportation under the Obama-era program called Deferred Action for Childhood Arrivals. But Mr Trump ended the program last September, and set March 5 as a deadline for resolving the issue.
The White House plan - which would put 1.8 million immigrants on a path to citizenship, boost border security, and dramatically curtail legal immigration - has been panned by Democrats. A series of bipartisan efforts have stalled.