President Donald Trump on Friday signed a $400 billion budget deal that sharply boosts spending and swells the federal deficit, ending a brief federal government shutdown that happened while most Americans were sleeping and most government offices were closed, anyway.

The House and Senate approved a bill to keep the government funded through March 23, overcoming opposition from liberal Democrats as well as tea party conservatives to endorse enormous spending increases despite looming trillion-dollar deficits. The House voted 240-186 to approve the bill just before dawn Eastern time, hours after the Senate had approved the measure on a 71-28 vote.

Trump tweeted Friday morning that he had signed the bill, writing that the U.S. military "will now be stronger than ever before." The budget bill "also means JOBS, JOBS, JOBS!" Trump tweeted.

He followed up with additiona tweets hammering Democrats and calling for the election of more Republicans in Congress.

Just signed Bill. Our Military will now be stronger than ever before. We love and need our Military and gave them everything — and more. First time this has happened in a long time. Also means JOBS, JOBS, JOBS! — Donald J. Trump (@realDonaldTrump) February 9, 2018

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. Sadly, we needed some Dem votes for passage. Must elect more Republicans in 2018 Election! — Donald J. Trump (@realDonaldTrump) February 9, 2018

Costs on non-military lines will never come down if we do not elect more Republicans in the 2018 Election, and beyond. This Bill is a BIG VICTORY for our Military, but much waste in order to get Dem votes. Fortunately, DACA not included in this Bill, negotiations to start now! — Donald J. Trump (@realDonaldTrump) February 9, 2018

The twin votes put to rest a brief federal freeze that relatively few would notice. Many who did quickly labeled it a pointless, head-scratching episode. The shutdown was the second partial government shutdown in three weeks.

The breakdown came largely in the Senate, when after a day of inaction, Republican Sen. Rand Paul of Kentucky went rogue and stalled a vote in protest over his party's willingness to bust the budget. But Democrats also had their divisions and wrangling, largely with liberal upset the measure were not tied to any plans to assist the "Dreamer" immigrants.

Most Democrats opposed the measure, following the lead of House Minority Leader Nancy Pelosi, D-Calif., who tried and failed to use the moment to secure a promise for a separate vote on immigration. Up to the final minutes, it was not clear the bill would pass in the House, and many Democrats held their votes, allowing the tally to creep slowly and giving no indication which way it might fall.

House Speaker Paul Ryan, R-Wis., urged Congress to avoid a "second needless shutdown in a matter of weeks — entirely needless."

In the end, 73 Democrats voted in favor of the bill in the House, while 67 Republicans opposed it.

There was far less drama in the Senate, where the measure sailed through by a 71-28 tally once Paul's protest ran its course.

The White House was forced to order the government shutdown shortly after midnight, but leaders quickly hustled to move before federal employees were due back at work, hoping to minimize the disruption.

The White House kept its distance from the quarreling on Capitol Hill. Trump did not tweet on the issue Thursday and aides did not try to assign blame.

Senate GOP leaders, however, were clearly irked by the debacle. In his attempt to sway Paul to relent, Texas Sen. John Cornyn declared his fellow Republican was "wasting everyone's time" and prompting a shutdown for "no good reason." But Paul, the resident contrarian, repelled suggestions to stand aside.

"I didn't come up here to be part of somebody's club. I didn't come up here to be liked," Paul said.

The budget agreement is married to a six-week temporary funding bill needed to keep the government operating and to provide time to implement the budget pact.

The bill includes huge spending increases sought by Republicans for the Pentagon along with a big boost demanded by Democrats for domestic agencies. Both sides pressed for $89 billion for disaster relief, extending a host of health care provisions, and extending a slew of smaller tax breaks.

It also would increase the government's debt cap, preventing a first-ever default on U.S. obligations that looms in just a few weeks. Such debt limit votes are usually enormous headaches for GOP leaders, but the increase means another vote won't occur before March 2019.

Senate leaders had celebrated the budget deal as a sign they had left behind some of their chronic dysfunction. Just three weeks ago, Senate Democrats sparked a three-day partial government shutdown by staging a filibuster on a spending bill, seeking relief for "Dreamer" immigrants who've lived in the country illegally since they were children.

Senate Democrats had no appetite for another shutdown.

House GOP leaders shored up support among conservatives for the measure, which would shower the Pentagon with money but add hundreds of billions of dollars to the nation's $20 trillion-plus debt.

House Democratic leaders opposed the measure — arguing it should resolve the plight of Dreamers — but not with all their might. Pelosi made it plain she wasn't pressuring her colleagues to kill the bill, which is packed with money for party priorities like infrastructure, combating opioid abuse and helping college students.

"She negotiated the deal. Her team was in on it," said top GOP vote counter Patrick McHenry, R-N.C. "And they were a 'no.' And at the end her team broke."

Pelosi continued to press Ryan for a promise to bring an immigration measure sponsored by Reps. Will Hurd, R-Texas, and Pete Aguilar, D-Calif., up for a vote. But many Democrats backed the spending measure without that assurance.

Ryan said again Thursday he was determined to bring an immigration bill to the floor this year — albeit only one that has Trump's blessing.

"We will solve this DACA problem," Ryan said just before the vote. "Once we get this budget agreement done ... we will focus on bringing that debate to this floor and finding a solution."

The episode was a clear defeat for Democrats who had followed a risky strategy to use the party's leverage on the budget to address immigration. Protection for the Dreamers under former President Barack Obama's Deferred Action for Childhood Arrivals program, or DACA, formally expires March 5 and there's no sign that lawmakers are making progress on an agreement to extend the program.

Republicans, too, had their disappointments. Many were sheepish or even angry about the bushels of dollars for Democratic priorities and the return next year of $1 trillion-plus deficits.

"I think the spending in this is reckless and irresponsible," said Rep. Thomas Massie, R-Ky., a conservative who is backed by the tea party.

But many other Republicans pointed to money they have long sought for the Pentagon, which they say needs huge sums for readiness, training and weapons modernization.

"It provides what the Pentagon needs to restore our military's edge for years to come," said Ryan.

Beyond $300 billion worth of increases for the military and domestic programs, the agreement adds $89 billion in overdue disaster aid for hurricane-slammed Texas, Florida and Puerto Rico, a politically charged increase in the government's borrowing cap and a grab bag of health and tax provisions. There's also $16 billion to renew a slew of expired tax breaks that Congress seems unable to kill.

"I love bipartisanship, as you know," said Sen. Jeff Flake, R-Ariz. "But the problem is the only time we discover bipartisanship is when we spend more money."