A brief US government shutdown ended early on Friday after Congress passed a funding bill that will keep the government open through March 23.

President Donald Trump tweeted that he signed the legislation before the start of the working day, ending the country's second shutdown this year.

"Just signed Bill. Our Military will now be stronger than ever before," Trump tweeted.

The House narrowly passed the bill, 240-186, after the Senate approved it earlier on Friday.

The hours-long shutdown began after midnight on Thursday when the current government funding expired.

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

It came after Republican Senator Rand Paul delayed the Senate vote over his objections to the massive budget measure, which lifts spending caps on US defence and domestic programmes by about $300bn. It also raises the government's debt ceiling until March 2019.

Paul told the Senate that the bill, which would raise the deficit, is the "definition of hypocrisy" and that it would "loot the treasury".

"I ran for office because I was very critical of [former] President [Barack] Obama's trillion-dollar deficits," Paul said.

The Republican senator did vote for a landmark tax overhaul bill in December that would add nearly $1.5 trillion to the national debt over 10 years.

Despite Paul's objections, the Senate passed the bill shortly after 1:00am local time (6:00 GMT) on Friday, sending it to the House where it took about three hours to approve.

No deal on DACA

This was the second time this year that the government shut down. In January, members of Congress failed to reach a deal on immigration, which Democrats had initially said would need to be part of any spending agreement.

On Wednesday, Democratic House minority leader Nancy Pelosi, spoke for a record eight hours on the House floor, calling for a permanent measure that protects the nearly 800,000 undocumented people, known as "Dreamers", who were brought to the US as children.

In September of last year, Trump announced he was ending the Deferred Action on Childhood Arrival (DACA) programme, giving Congress until March 5 to come up with a permanent solution.

The budget agreement "does not have my support, nor does it have the support of a large number of members of our caucus," Pelosi said, as reported by the Associated Press earlier this week.

Senate Republicans have vowed to hold a debate on immigration later this month, but Dreamers and their supporters worry a solution will not be found before the March 5 deadline.

Al Jazeera's Kimberly Halkett, reporting from Washington, said the budget legislation is significant because it is bipartisan.

"Republicans got a lot of what they wanted in here, namely big increases for military spending, but Democrats got what they wanted as well, for the mostpart," Halkett said.

But "in the end, it was Democrats who caved" on their demand for protection for the Dreamers, she added.

"This still now has to be worked out and will be a focus of debate in the coming weeks, given the fact that Donald Trump ended those Obama-era protections," Halkett said.