The U.S. Senate on Saturday passed a $1.1 trillion spending bill that lifts the threat of a government shutdown as Congress attempts to wrap up a two-year legislative session marked by bitter partisanship and few major accomplishments.
The Senate's 56-40 vote sends the measure to President Barack Obama, who is expected to sign it into law before an extension of federal spending authority expires at midnight on Wednesday.
Passage of the 1,603-page bill was a long, tough struggle in the Senate and the House of Representatives marked by weeks of closed-door haggling over controversial policy changes and bitter disputes over financial regulations and Obama's immigration order.
The legislation largely eliminates government shutdown worries for financial markets through next fall by funding most government agencies through September 2015.
Read More Obama to discuss economic ideas with CEOs
The Department of Homeland Security will be treated differently, getting a funding extension only through Feb. 27, by which time Republicans will control both chambers of Congress.
Republicans insisted on the shorter leash for the department so that they can try to deny the agency any funds for implementing Obama's recent order easing deportations for millions of undocumented immigrants.
The Senate vote, taken during a rare Saturday session triggered by conservative senators who refused to waive some procedural hurdles, closed the latest chapter in a four-year-long battle between Democrats and Republicans over U.S. fiscal policy during an era of large budget deficits.
These battles are expected to resume next year but with a twist: Republicans, having won the Nov. 4 congressional elections, take control of the Senate from Democrats with a 54-46 majority and will enjoy a larger majority in the House.
Nonetheless, Republicans will still need cooperation from Democrats in the Senate, where 60 out of 100 votes are needed to advance most major bills.
The House also struggled with the bill, narrowly passing it after Democrats feuded over provisions to weaken derivatives regulations in the Dodd-Frank financial reform law and to allow more big-money campaign donations to national political parties.
But those splits were overtaken by Republican divisions in the Senate that twisted the chamber into knots for the past two days.
Texan strikes again
Republican Senator Ted Cruz, a Tea Party darling and fierce opponent of Obama's immigration executive order, insisted on an up-or-down vote on denying funding for that order.
Cruz, a potential 2016 presidential candidate, was the ringleader in the October 2013 government shutdown that lasted 16 days as he insisted on gutting Obama's healthcare law.
Read More Pelosi whips against spending bill, Obama
As in 2013, this latest budget fight ended with Cruz failing to score a victory and Democrats bashing Republicans for again raising the specter of a government shutdown.
A revolt by House Democratic leader Nancy Pelosi, a longtime Obama ally, and freshman Democratic Senator Elizabeth Warren over a provision to ease Wall Street banking regulations fed tensions on Capitol Hill all week.
The House vote was delayed for seven hours on Thursday after Democrats balked at provisions to roll back part of the Dodd-Frank financial reform law, an early legislative achievement of the Obama administration that was passed in response to the 2008 financial crisis and aimed to rein in risk-taking by Wall Street. Democrats also objected to the provision allowing bigger political donations.
The banking provision would kill planned restrictions on derivatives trading by large banks, allowing them to continue trading swaps and futures in units that benefit from federal deposit insurance and Federal Reserve loans.
Banks argue the provision is ineffective.
The spending bill provides for a slight increase in Pentagon war funding, which would total $64 billion for this fiscal year. Some of the money is for combating Islamic State in Iraq and Syria.
Other high-priority items include nearly $5.5 billion to help contain the Ebola virus, including Defense Department efforts in West Africa.
Read More Politicians and industry respond to Obama's immigration announcement
Internal Revenue Service spending would be cut and Republicans also inserted initiatives ranging from prohibiting funding for the Environmental Protection Agency to regulate lead content in ammunition and fishing tackle, to stopping the transfer or release of Guantanamo detainees into the United States.
Republicans have pledged to use spending bills and other legislation next year to attack a range of government regulations, which they argue hurt the U.S. economy.