Updated

The House of Representatives voted early Friday to approve a massive budget package that lifts spending caps while funding the government through March 23, all but ending a brief shutdown after a tumultuous night on Capitol Hill.

The 240-186 vote sends the $400 billion spending plan to President Trump, who has promised to sign it.

The budget deal, which includes a stopgap temporary measure to keep the government running, allows $300 billion more for the military and other programs over two years. The agreement also 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.

Passage of the measure came over the opposition of Democratic leaders who demanded the promise of a vote to protect "Dreamer" immigrants brought to the country illegally as children.

House Speaker Paul Ryan, R-Wis., called the budget plan a “true compromise.”

“My commitment to working together on an immigration measure that we can make law is a commitment,” he said.

Democrats like House Minority Leader Nancy Pelosi wanted a commitment on a bill to help “Dreamers.” Such protections are about to expire in early March, a result of President Trump ending the Obama-era Deferred Action for Childhood Arrivals, or DACA, program.

But the bigger drama played out on the Senate side. A last-minute maneuver by Sen. Rand Paul, R-Ky., delayed consideration of the bipartisan budget package in that chamber past midnight.

The result: the government endured a short-term shutdown in the wee hours of the morning, though most would never feel its effects.

Paul, though, objected on fiscal conservative grounds that the plan irresponsibly busted through budget caps and would grow the deficit even more.

"I ran for office because I was very critical of President Obama's trillion-dollar deficits," the Kentucky senator said. "Now we have Republicans hand in hand with Democrats offering us trillion-dollar deficits. I can't in all honesty look the other way."

At one point, an exasperated Sen. Thom Tillis, R-N.C., took to the Senate floor to lambaste Paul for what Tillis described as "theater."

"We can right now provide certainty to people who expect government to be open or we can play this game until 1 a.m.," said Tillis, who reminded Paul that "you have to convince 51 or 60 senators that your idea is good enough to support."

"You can make a point all you want, but points are forgotten," Tillis added. "There aren't a whole of history books about great points in the U.S. Senate."

Shortly after 10 p.m., Senate Majority Whip John Cornyn, R-Texas, made six separate unanimous consent requests to hold a vote on the budget. Each time, Paul objected.

"I don't know why we're burning time here," Cornyn said before accusing Paul of "effectively shutting down the government ... for no real reason."

"It makes no sense to me," Cornyn added. "It will not accomplish anything."

As Paul stood firm, the Trump administration announced it was preparing for a "lapse" in appropriations, suggesting that officials expected a short shutdown.

The Senate eventually approved the bill.

Senate Minority Leader Chuck Schumer, D-N.Y., praised the plan in a statement shortly after the vote, writing that, "Funding for education, infrastructure, fighting drug abuse, and medical research will all, for the first time in years, get very significant increases, and we have placed Washington on a path to deliver more help to the middle class in the future.”

Late Thursday, House GOP leaders advised members to prepare for votes "very roughly between" 3 a.m. and 6 a.m. Friday.

Trump has been urging Republicans and Democrats to support the Senate bill, tweeting that lawmakers must “must support our troops and support this bill.”

The House Freedom Caucus, the chamber’s fiscally conservative wing, also opposed the bill out of concerns that it would lead to more government spending.

“The … caucus opposes the deal to raise spending caps on discretionary spending by nearly $300 billion over two years,” the roughly 30-member group said Wednesday. “We support funding for our military, but growing the size of government by 13 percent adds to the swamp instead of draining it. This is not what the American people sent us here to do.”

Fox News' Chad Pergram and The Associated Press contributed to this report.