WASHINGTON (TNS) — Congress achieved an ambitious two-year budget agreement Friday, but in doing so, reignited ideological factions on deficit spending and immigration that are likely to flare as lawmakers turn to these issues next, ahead of a daunting midterm election season.

The rare bipartisan agreement dispatched $300 billion in new spending over this year and next for military and nondefense programs, plus $90 billion in disaster aid. It also ended a nearly nine-hour government shutdown that began when lawmakers failed to meet the midnight deadline, blocked by GOP Sen. Rand Paul, despite a grueling all-night session.

But President Donald Trump, in signing the bill into law, foreshadowed the bitter fights ahead. "Without more Republicans in Congress, we were forced to increase spending on things we do not like or want in order to finally, after many years of depletion, take care of our Military," Trump tweeted. "Sadly, we needed some Dem votes for passage. Must elect more Republicans in 2018 Election!"

The Kentucky senator, a sometimes Trump ally, forced the brief government shutdown by using Senate rules to run out the clock before voting could begin. In floor speeches Thursday night, Paul lambasted his fellow Republicans for supporting a bill that will worsen the deficit. He also pleaded his case to Trump in a phone call during the standoff.

Nevertheless, the Senate passed the measure 71-28, followed by House approval, 240-186.

Though federal offices were largely unaffected by the off-hours shutdown, it was the second such disruption in less than a month, turning what was once a drastic, rarely-seen tactic into something less surprising on Capitol Hill.

Senate Majority Leader Mitch McConnell moves next to the difficult issue of immigration, with a procedural vote set for Monday. He has promised a free-wheeling debate in an attempt to develop a legislative compromise on the status of the young immigrants known as "Dreamers," who face deportation as Trump ends the Obama-era Deferred Action for Childhood Arrivals program that protected them.

"There's no secret plan here to try to push this in any direction, and the Senate's going to work its will," McConnell said. "I hope that we will end up passing something."

McConnell was pressured to prioritize the immigration issue after the earlier shutdown in January, when Senate Democrats refused to support a stopgap spending bill until they won a commitment from the GOP leader to address the issue.

Even though court action is temporarily keeping DACA running, Democrats are under enormous pressure to protect the nearly 700,000 immigrants who came to the country illegally as children. Under the program, they are able to live and work in the U.S.

Many of the Dreamers and their advocates stayed up late with lawmakers Thursday, occupying House Minority Leader Nancy Pelosi's office for hours, and knocking on the doors of Democrats and Republicans as they pushed Congress to stop them from being kicked out of the country. Some noted on Twitter that they were not, as White House chief of staff John F. Kelly said, "lazy."

Pelosi, taking a page from the playbook of filibustering senators, tried to leverage the minority's role by commandeering the House floor earlier in the week in a last-ditch effort to push Speaker Paul D. Ryan to provide the same commitment to address the issue that McConnell had given in the Senate.

Ryan, who needed Democratic votes to pass the budget deal, promised to bring a bill forward, but his assurances were too vague to satisfy Democrats. Even so, despite threatening to withhold scores of votes, many Democrats supported the spending deal.

Liberal groups lambasted Pelosi and Senate Minority Leader Charles E. Schumer, D-N.Y., for caving, but the more conservative members of their caucuses were not as eager to risk being saddled with choosing the fates of Dreamers over keeping federal offices open, particularly as they prepare to face voters in the fall election.

"Unfortunately, the Dreamers have become pawns in this whole process," said Rep. Raul Grijalva, D-Ariz.

Lawmakers are struggling to develop a bipartisan solution that would include $25 billion that Trump wants for his promised border wall and other border security measures. It would protect 1.8 million Dreamers, beyond those under DACA, but also impose new restrictions on visas for immigrant family members or those from underrepresented countries in the so-called visa lottery program that Trump wants to eliminate.

Sen. Lindsey Graham, R-S.C., says the most Congress maybe able to accomplish is a temporary measure to continue the DACA program for another year or more.

Some Democrats dismiss such a short-term compromise. "I very seldom disagree publicly with my friend Lindsey, but that's a horrible outcome," said Sen. Richard J. Durbin, D-Ill., who has long partnered with Graham on bipartisan immigration legislation. "We cannot do that. The Dreamers have said, 'Do not do that to us and our families.'"

At the same time, the White House is set to release Trump's budget on Monday, which is sure to spark the debate over deficits from fiscal conservatives, including Paul and the House Freedom Caucus, which opposed the two-year budget deal, sounding warnings against rising debt.

The era of $1 trillion annual deficits will soon return, thanks to the combination of the budget deal and the 2017 GOP tax cut plan. Deficits have not reached those levels in years. President Barack Obama cut them nearly in half in his second term.

"When Republicans are in power, it seems there is no conservative party," Paul said during the overnight debate. He wanted the Senate to vote on his amendment to stick to 2011 budget caps, but was denied, and called the package "a bipartisan looting of the treasury."