The US Congress has ended a brief government shutdown by reaching a wide-ranging deal that is expected to push budget deficits into the $1 trillion-a-year zone.

The bill passed by a wide margin in the Senate and survived a rebellion of 67 conservative Republicans in the House of Representatives thanks to the support of some Democrats.

Those conservatives were mainly angry about non-military spending increases.

US President Donald Trump signed the measure into law, ending a government shutdown that began just after midnight, when Congress was still debating the budget deal.

It was the second shutdown this year under the Republican-controlled Congress and Mr Trump, who played little role in attempts by party leaders this week to end months of fiscal squabbling.

The deal is the fifth temporary government funding measure for the fiscal year that began on 1 October and replenishes federal coffers until 23 March, more time for a full-year budget to be written.

It also extends the US government's borrowing authority until March 2019, sparing Washington politicians difficult votes on debt and deficits until after mid-term congressional elections in November.

Once known as the party of fiscal conservatives, the Republicans and Mr Trump are now quickly expanding the US budget deficit and its $20 trillion national debt.

Their sweeping tax overhaul bill approved in December will add an estimated $1.5 trillion to the national debt over ten years.

Nearly $300 billion in new spending included in the bill approved today will ensure the annual budget deficit will exceed $1 trillion in 2019, said the Committee for a Responsible Federal Budget, a private fiscal policy watchdog group in Washington.

Today’s budget deal allows for $165 billion in additional defence spending over two years that will help Mr Trump deliver on his promise to rebuild the military.

That won over many Republicans but some were still furious over the $131 billion extra made available for non-military spending, including health and infrastructure.

None of the added spending will be offset by budget savings elsewhere or revenue increases, relying instead on government borrowing.

There also is no offset reduction for nearly $90bn in new disaster aid for US states and territories destroyed by hurricanes or wildfires.

The brief shutdown in Washington came at a sensitive time for financial markets. Stocks plunged yesterday on heavy volume, throwing off course a nearly nine-year bull run. The S&P500 slumped 3.8%.

Markets barely flinched at the last shutdown in January, but that was before a dizzying sell-off that started on 30 January amid concerns about inflation and higher interest rates.

House Democratic leader Nancy Pelosi and others in her party had opposed the bill because Republican House leaders would not guarantee her a debate later on steps to protect about 700,000 "Dreamer" immigrants from deportation.

These young people were brought illegally to the country as children years ago, mostly from Mexico.

Mr Trump said in September he would end by 5 March former Democratic President Barack Obama's Deferred Action for Childhood Arrivals (DACA) programme that protects the Dreamers from deportation.

Mr Trump urged Congress to act before then. Senate Republicans have pledged to hold a separate immigration debate this month.

House Speaker Paul Ryan had not offered Ms Pelosi an equivalent promise in the house, although he said in a speech before today’s vote that he would push ahead for a deal.

"My commitment to working together on an immigration measure that we can make law is a sincere commitment," he said. "We will solve this DACA problem."

But Ms Pelosi said Mr Ryan's words fell short, accusing him of not having "the courage to lift the shadow of fear from the lives of" Dreamers who face the prospect of deportation.