Congressional leaders finalised a sweeping $1.3trn (€1.05trn) budget bill on Wednesday that substantially boosts military and domestic spending.
But it leaves behind young immigrant "Dreamers", deprives president Donald Trump of some of his border wall money and takes only incremental steps to address gun violence.
As negotiators stumbled towards an end-of-the-week deadline to fund the government or face a federal shutdown, House Speaker Paul Ryan dashed to the White House amid concerns Mr Trump's support was wavering.
The White House later said the president backed the legislation, even as some conservative Republicans baulked at the size of the spending increases and the rush to pass the bill.
Talks continued into Wednesday evening before the 2,232-page text was finally released.
"No bill of this size is perfect," Mr Ryan said. "But this legislation addresses important priorities and makes us stronger at home and abroad."
Leaders still hoped to start voting as soon as today. A stopgap measure may be needed to ensure federal offices are not hit with a partial shutdown at midnight on Friday when funding for the government expires.
Negotiators have been working for days - and nights - on details of the bill, which is widely viewed as the last major piece of legislation likely to move through Congress in this election year. Politicians in both parties sought to attach their top priorities.
Two of the biggest remaining issues had been border wall funds and a legislative response to gun violence after the clamour for action following recent school shootings, including the one in Parkland, Florida.
On guns, leaders agreed to tuck in bipartisan provisions to bolster school safety funds and improve compliance with the criminal background check system for firearm purchases. The bill states that the US Centres for Disease Control and Prevention can do research on gun violence, though not advocacy, an idea Democrats pushed.
But there was no resolution for Dreamers, the young immigrants who have been living in the United States illegally since childhood, but whose deportation protections are being challenged in court after Mr Trump tried to end the Deferred Action for Childhood Arrivals programme, or DACA.
Democrats temporarily shut down the government earlier this year as they fought for that protection. But the issue only rose to a discussion item when Mr Trump made a late-hour push for a deal in exchange for $25bn (€20bn) in border wall funds.
Instead, MrTrump is now poised to win $1.6bn (€1.3bn) for barriers along the border, but none of it for the new prototypes he recently visited in California.
Less than half the nearly 95 miles of border construction, including levees along the Rio Grande in Texas, would be for new barriers, with the rest for repair of existing segments.
In one win for immigrant advocates, negotiators rejected Mr Trump's plans to hire hundreds of new Border Patrol and immigration enforcement agents.
"We are disappointed that we did not reach agreement on Dreamer protections that were worthy of these patriotic young people," said House Minority Leader Nancy Pelosi.
The core purpose of the bill is to increase spending for military and domestic programmes that have been sharply squeezed under a 2011 agreement that was supposed to cap spending. It gives Mr Trump a huge budget increase for the military, while Democrats scored wins on infrastructure and other domestic programs that they failed to get under president Barack Obama.