WASHINGTON, DC - FEBRUARY 09: Lights shine down Pennsylvania Avenue leading to the U.S. Capitol in the early hours of Friday morning on February 9, 2018 in Washington, DC. Despite an attempt by Sen. Rand Paul (R-KY) to slow down the process, the Senate passed bipartisan legislation to continue to fund the government and lift strict budget caps. With the government officially in a shut- down, the legislation now goes to the House of Representatives which is expected to vote to reopen the Government early Friday morning. (Photo by Mark Wilson/Getty Images)

WASHINGTON — 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 home in bed and most government offices were closed.

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 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 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 urged Congress to avoid a “second needless shutdown in a matter of weeks — entirely needless.”

There was far less drama in the Senate, where the measure sailed through 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 House vote ensured most employees would report for work as usual. Under federal law, passage of the measure is enough to call off the shutdown.

The White House kept its distance from the quarreling on Capitol Hill. Trump did not tweet 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, Sen. John Cornyn of Texas 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 filibustering 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 such as 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 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 — and we will get this done for no matter how long it takes for us to stay here — we will focus on bringing that debate to this floor and finding a solution.”

The episode was a clear defeat for those 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 formally expires next month 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 about the bushels of dollars for Democratic priorities and the return next year of $1 trillion-plus deficits.

But they 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,” Ryan said.

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.”