* Senate, House approve stopgap funding and budget bill
* Measure will go next to President Donald Trump to sign
* Shutdown caused by Senator Rand Paul's deficit dissent
* Package's debt ceiling extension could help calm markets (Adds Noem, Ryan comments)
WASHINGTON, Feb 9 (Reuters) - The U.S. House of Representatives joined the Senate early on Friday morning in approving a bill to end an overnight federal shutdown, sparing
Republicans further embarrassment and averting serious
interruption of the government's business.
The stopgap funding and budget measure, approved by a 240-186 House vote, will go next to President Donald Trump. The White House said in a statement that he will sign it into law, which would extend government funding through March 23.
The shutdown, which started at midnight, was the second this year under the Republican-controlled Congress and Trump, who played little role in attempts by party leaders earlier this week to head it off and end months of fiscal squabbling.
A carefully crafted, bipartisan stopgap funding and budget package was introduced with confidence earlier this week by Senate leaders, who predicted swift passage before the expiration at midnight on Thursday of current funding authority.
But in an unexpected turn of events, the deadline was missed because Kentucky Republican Senator Rand Paul, objecting to deficit spending in the bill, engaged in a nine-hour, on-again, off-again protest and floor speech that leaders could not stop.
Paul's dissent dragged the Senate proceedings into the wee hours past the deadline, underscoring the persistent inability of Congress and Trump to deal efficiently with Washington's most basic fiscal obligation of keeping the government open.
"Republican majorities in the House and Senate have turned the (budget) process into an embarrassing spectacle, running from one crisis directly into the next," said Democratic Representative Nita Lowey prior to the House vote.
'LOOT THE TREASURY'
After an all-night session of debating and voting, the bill ending the shutdown finally won House passage only after Democrats provided enough votes to offset the opposition of 67 Republicans, a remarkable rebellion in the party's ranks.
While Paul's performance in the Senate strained the patience of his colleagues, he focused on the same concern that caused so many House Republicans to oppose the bill - deficit spending.
The budget bill raises military and domestic spending by almost $300 billion over the next two years. With no offsets in the form of other spending cuts or new tax revenues, that additional spending will be financed by borrowed money.
That part of the overall package was a bipartisan attempt by Senate leaders to end for many months, at least beyond November's midterm congressional elections, the fiscal policy quarrels that increasingly consume Congress.
But the deficit spending in the bill will add more red ink to Washington's balance sheet and further underscore a shift in Republican thinking that Paul was trying to draw attention to.
Once known as the party of fiscal conservatism, the Republicans and Trump are quickly expanding the nation's 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 debt over 10 years, an accumulation of past years of annual budget deficits.
The $300 billion in spending included in the bill just approved 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.
"I ran for office because I was very critical of President Obama's trillion-dollar deficits," Paul told fellow senators.
"Now we have Republicans hand in hand with Democrats offering us trillion-dollar deficits. I can't ... in good faith, just look the other way because my party is now complicit in the deficits. Really who is to blame? Both parties," he said.
Paul voted for the deficit-financed tax bill in December.
South Dakota Republican Representative Kristi Noem told Reuters she voted against the bill because it increases non-defense spending and raises the federal debt ceiling.
"To increase domestic spending and raise the debt ceiling was coupling two very bad policy decisions and with no reforms tied to it. It was very disappointing," she said.
The 5-1/2-hour shutdown in Washington came at a sensitive time for financial markets. Stocks plunged on Thursday in New York on heavy volume, throwing off course a nearly nine-year bull run. The S&P 500 slumped 3.8 percent.
Markets barely flinched at the last shutdown in January, but that was before a dizzying selloff that started on Jan. 30 amid concerns about inflation and higher interest rates.
Uneasiness in the markets could be partially eased by the bill's extension of the federal debt ceiling to March 2019, preventing further near-term confrontations over that issue.
On another front, 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. Trump said in September he would end by March 5 former Democratic President Barack Obama's Deferred Action for Childhood Arrivals (DACA) program that protects the Dreamers from deportation.
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 Pelosi an equivalent promise in the House. It was not immediately clear if the Democrats extracted a firmer commitment from Ryan on the issue in exchange for their votes to end the shutdown.
Immediately following the vote, Ryan said in a statement: "Once the president signs this bill into law, we will have a clear path to pursue our ambitious agenda for 2018."
He did not specifically mention legislation that Democrats have been urging to protect the Dreamers.
Earlier in the morning before the vote, Ryan pleaded for votes in floor remarks and said, "My commitment to working together on an immigration measure that we can make law is a sincere commitment ... We will solve this DACA problem."
Minutes after midnight, when the short-lived shutdown began, the U.S. Office of Personnel Management sent a notice to millions of federal employees telling them to check with their agencies on whether they should report to work on Friday.
It was not immediately clear just before daybreak on Friday how various agencies were handling the matter.
(Additional reporting by Eric Beech, Makini Brice, Katanga Johnson and Doina Chiacu; Writing by Kevin Drawbaugh; Editing by Matthew Mpoke Bigg)