The Senate compromise still has a perilous path through the US House of Representatives, as fiscal hawks anxious about federal spending and liberals angry over the lack of an immigration deal threaten opposition.
The bill includes $300bn (£216bn) in spending increases for both defence and domestic programs, with military spending getting an $80bn boost in the first fiscal year, followed by $85bn in the second.
The House on Tuesday passed its fifth stop-gap spending bill, a proposal that would fund domestic programs through March 23 and also give the Pentagon a full-year budget of $659 billion.
McConnell, Ryan and President Trump have all said they want to find a permanent fix for the roughly 700,000 people enrolled in the DACA program which is set to expire March 5 under terms set by Trump a year ago.
"Bad, bad, bad agreement", Rep. Jim Jordan, R-Ohio, said.
Shortly before midnight Wednesday night, McConnell took to the Senate floor to file the budget deal legislative text and file cloture on it. CNN reports staff was drafting the legislation until right before it was filed - a reminder, this is a very, very wide ranging, large scale deal. "It is as simple as that", said Illinois Rep. Luis Gutierrez, a longtime Democratic advocate of immigration reform.
The deal will require Congress to pass a stopgap spending bill for only a few weeks while lawmakers write the two-year spending legislation.
Unlike the past agreements to avoid the steep "sequester" cuts in 2013 and 2015, the deal announced Wednesday would be only partially offset with spending reductions or new revenue elsewhere, making it a nonstarter for many conservative Republicans - especially after the GOP tax package added almost $1.5 trillion over the decade to deficits.
Stock market plunges again, enters first correction in 2 years
There was another decent swing on the markets on Wednesday, but it was dwarfed by the wild moves over the last few days. The Nikkei in Japan closed down 4.7%, China's main stock index closed down 3.3%, and Australia's closed down 3.2%.
"No one would suggest it is ideal", McConnell said in a statement hailing the deal. "Give us a vote". McConnell's bill fails to hit the numbers set by the President, which aimed at a $52 billion increase to defense spending from the 2017 budget.
The measure is stuffed with other fiscal provisions, including a major disaster relief package for regions hard-hit by last year's devastating storms and a one-year suspension of the debt limit, the amount the U.S. Treasury can borrow to pay the nation's bills.
The defense cap would increase to $629 billion for fiscal 2018 and $647 billion for fiscal 2019 - a total of $165 billion over the existing cap.
The $300 billion agreement would increase defense funding by $80 million in the current fiscal year and $85 billion in the next fiscal year, which begins October 1. It is expected to make some changes, pass the bill and send it back to the House for a vote.
House Minority Leader Nancy Pelosi (D-Calif.) opposes the legislation because it does not provide protections for the more than 800,000 recipients of the Deferred Action for Childhood Arrivals (DACA) program. But its fate in the House remains unclear, with both Democrats and Republicans facing internal party divisions over the deal.
The California congresswoman has called for the bill to include a provision shielding so-called Dreamers, young immigrants who entered the United States illegally as children, from deportation.
Mr Brooks, a member of the Freedom Caucus, a congressional group of budget hawks, dubbed the bill a "debt junkie's dream".
"But when you add them all up, it adds to an terrible lot of spending".
"I have had the privilege of reading the testimony from Dreamers, I still have more", she said, receiving applause in the chamber.