WASHINGTON (AP) -- Congressional leaders finalized a sweeping $1.3 trillion budget bill Wednesday that substantially boosts military and domestic spending but leaves behind young immigrant "Dreamers," deprives President Donald Trump some of his border wall money and takes only incremental steps to address gun violence.
As negotiators stumbled toward 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 Trump's support was wavering. The White House later said the president backed the legislation, even as some conservative Republicans balked 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," 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 Thursday. A stopgap measure may be needed to ensure federal offices aren't hit with a partial shutdown at midnight 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. Lawmakers 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 clamor for action following recent school shootings, including the one in Parkland, Florida.
On guns, leaders tentatively 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 U.S. Centers 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 Trump tried to end the Deferred Action for Childhood Arrivals program, 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 Trump made a late-hour push for a deal in exchange for $25 billion in border wall funds.
Instead, Trump is now poised to win $1.6 billion 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 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 emerging plan removes a much-debated earmark protecting money for a rail tunnel under the Hudson River. The item was a top priority of Trump's most powerful Democratic rival, Senate Minority Leader Chuck Schumer of New York, but Trump vowed to veto the bill over the earmark. Under the legislation, the project would remain eligible for funding, however, and a Schumer aide said it was likely to win well more than half of the $900 million sought for the project this year.
The core purpose of the bill is to increase spending for military and domestic programs that have been sharply squeezed under a 2011 agreement that was supposed to cap spending. It gives 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.
That largesse has drawn opposition from some fiscal conservatives and could make passage a potentially tricky process.
Last month, Kentucky Sen. Rand Paul triggered a brief government shutdown over his objections to the deficit spending. On Wednesday, he tweeted his opposition to the emerging legislation, known as an "omnibus."
"It's a good thing we have Republican control of Congress or the Democrats might bust the budget caps, fund planned parenthood and Obamacare, and sneak gun control without due process into an Omni ... wait, what?" Paul tweeted.
Most essential was support from Trump, who has been known to threaten to veto legislation even when his team is involved in the negotiations.
Word of Trump's discontent sent Ryan to the White House, where he was invited to a face-to-face with the president, with Senate Majority Leader Mitch McConnell on the phone.
White House aides said the president's support was never in doubt, but one senior White House official said the president was concerned that details of the package weren't being presented as well as they could be, both to members of Congress and the public.
The group discussed how they could better sell the package, said the official, who was granted anonymity to discuss the private conversation.
"The president and the leaders discussed their support for the bill," said White House Press Secretary Sarah Huckabee Sanders, adding that it would fund Trump priorities such as wall construction, add money to combat the opioid crisis and provide new infrastructure spending.
Both parties touted $4.6 billion in total funding to fight the nation's opioid addiction epidemic, a $3 billion increase. More than $2 billion would go to strengthen school safety through grants for training, security measures and treatment for the mentally ill. Medical research at the National Institutes of Health, a longstanding bipartisan priority, would receive a record $3 billion increase to $37 billion. Funding was also included for election security ahead of the 2018 midterms.
Child care and development block grants would receive a huge $2.4 billion increase to $5.2 billion. And an Obama-era transportation grant program known as TIGER would see its budget tripled to $1.5 billion. Head Start for preschoolers would get a $610 million boost, while an additional $2.4 billion would go for child care grants.
Associated Press writers Jill Colvin, Alan Fram and Matthew Daly contributed.