WASHINGTON — Congress cleared a $1.1 trillion spending bill for President Barack Obama’s signature after a day of Senate intrigue capped by a failed, largely symbolic Republican challenge to the administration’s new immigration policy.

The vote late Saturday night was 56-40 in favor of the measure, which funds nearly the entire government through the Sept. 30 end of the fiscal year. It also charts a new course for selected shaky pension plans covering more than 1 million retirees, including the possibility of benefit cuts.

The Senate passed the bill on a day Democrats launched a drive to confirm two dozen of Obama’s stalled nominees to the federal bench and administration posts, before their majority expires at year’s end.

Several Republicans blamed tea party-backed Texas Sen. Ted Cruz for giving the outgoing majority party an opportunity to seek approval for presidential appointees, including some that are long-stalled.

It was Cruz who pushed the Senate to cast its first vote on the administration’s policy of suspending the threat of deportation for an estimated four million immigrants living in the country illegally. He lost his attempt Saturday night, 74-22, although Republican leaders have vowed to bring the issue back after the party takes control of the Senate in January.

“If you believe President Obama’s amnesty is unconstitutional, vote yes. If you believe President Obama’s amnesty is consistent with the Constitution, vote no,” he said.

Senate Majority Leader Harry Reid rebutted instantly, saying Cruz was “wrong, wrong, wrong on several counts,” and even Republicans who oppose Obama’s policy abandoned the Texan.

The spending bill, which cleared the House on Thursday, was the main item left on Congress’ year-end agenda, and exposed fissures within both political parties in both houses.

It faced opposition from Democratic liberals upset about the repeal of a banking regulation and Republican conservatives unhappy that it failed to challenge Obama’s immigration moves.

While the legislation assures funding for nearly the entire government until next fall, it made an exception of the Department of Homeland Security. Money for the agency will run out on Feb. 27, when Republicans intend to try and force the president to roll back an immigration policy that removes the threat of deportation from millions of immigrants living in the United States illegally.

The legislation locks in spending levels negotiated in recent years between Republicans and Democrats, and includes a number of provisions that reflect the priorities of one party or the other, from the environment to abortion to the legalization of marijuana in the District of Columbia.

One, which drew vehement objections from the Democrats, would repeal a regulation imposed on banks in the wake of the near economic collapse of 2008. Critics called it a bailout for large financial institutions, but more than 70 House Democrats voted for it previously, and Obama made clear he didn’t view it as a deal-killer.

The pension provision was a bipartisan agreement that opens the door for the first time to benefit cuts for current retirees covered by multi-employer funds in shaky financial condition.

Supporters said it would protect retirement income to the maximum extent possible without also endangering the solvency of the government fund that guarantees multi-employer plans. Critics said it posed a threat to the pension recipients, and that it could also become a precedent for other pensioners.

Immigration was at the heart of the day’s events in the Senate.

Cruz seized on the issue late Friday night when he tried to challenge the bill. That led swiftly to the unraveling of an informal bipartisan agreement to give the Senate the weekend off, with a vote on final passage of the bill deferred until early this coming week.

That, in turn, led Reid, D-Nev., to call an all-day Senate session devoted almost exclusively to beginning time-consuming work on confirmation for 13 judicial appointees and 11 nominees to administration posts.

The list included Carolyn Colvin to head the Social Security Administration and Vivek Murthy as surgeon general.

As the day wore on, senators were forced to spend hour after hour on the Senate floor to cast their votes. One, Sen. Mary Landrieu, D-La., sat at her desk quietly for awhile reading a book.

By evening, cocktail hour in the East, strains of Christmas carols could be heard from behind the closed doors of rooms that surround the chamber.

Republicans tried to slow the nomination proceedings, but several voiced unhappiness with Cruz, a potential presidential candidate in 2016.

“I’ve seen this movie before, and I wouldn’t pay money to see it again,” said Sen. Johnny Isakson, R-Ga., recalling Cruz’ leading role a year ago in events precipitating a 16-day partial government shutdown that briefly sent GOP poll ratings plummeting.

Cruz, in turn, blamed Reid, saying his “last act as majority leader is to, once again, act as an enabler” for the president by blocking a vote on Obama’s policy that envisions work visas for an estimated 5 million immigrants living in the country illegally.

Reid blamed a “small group of Senate Republicans” for the turn of events.

Asked if Cruz had created an opening for the Democrats, Sen. Orrin Hatch, R-Utah said, “I wish you hadn’t pointed that out.”

Hatch added, “You should have an end goal in sight if you’re going to do these types of things and I don’t see an end goal other than irritating a lot of people.”

The GOP leader, Kentucky Sen. Mitch McConnell, made no public comment on the events, even though Cruz suggested Friday night McConnell and House Speaker John Boehner, R-Ohio, should not be entirely trusted to keep their pledge to challenge Obama’s immigration policy.

“We will learn soon enough if those statements are genuine and sincere,” Cruz said.