Congressional leaders finalized a deal on Thursday to fund the government through next fall and are now considering a short-term extension of a payroll tax holiday and jobless benefits that would affect millions of Americans next year.

After a marathon round of negotiations, Democrats and Republicans signed off on a $1 trillion spending bill to keep the government funded through next fall, and that plan is expected to be approved by the full House and Senate on Friday, hours before many federal agencies would have been forced to shutter their doors.

But sticking points remained over how to pay for a year-long extension of a payroll tax holiday, jobless benefits and to avert a scheduled pay decrease for physicians serving Medicare patients. So negotiators are now actively considering a $40-billion, two-month extension on those measures.

A two-month extension would “make sure people continue to get their … payroll tax holiday and also the unemployment benefits and also doctors would be able to continue to do their work on Medicare patients,” Senate Majority Leader Harry Reid (D-Nev.) told reporters as he left the Capitol Thursday night. Reid added that he still hoped for a longer-term deal on those matters.

But it would also reignite a battle over the issue just as President Barack Obama is campaigning for reelection. A senior administration official said short-term extension would meet Obama’s principle that taxes don’t go up on the middle class, but they were withholding a fuller analysis until they saw a bill.

On Thursday night, Reid also filed a procedural motion to cut off debate on the House-passed payroll bill, setting up a vote as late as Saturday morning. The bill could be used as the vehicle for a final year-end deal, sources say.

Negotiations on a year-long extension over the payroll tax plan — which has been demanded by Obama — are expected to continue Friday.

“Everything is still moving along,” said Sen. Chuck Schumer (D-N.Y.) after leaving a Thursday night meeting with other Democratic leaders.

By Thursday afternoon, expectations were growing that an agreement could be reached that would allow the House and Senate to vote on a government funding bill by Friday. Sources said an increase in funding for the enforcement of the Dodd-Frank financial services law and to change language tightening travel restrictions to Cuba helped generate Democratic support.

Staff for Senate leaders had been holed up in the backrooms of the Capitol, deliberating over weighty issues involving how the costs of the extensions should be paid for and how to resolve other sticking points, such as a provision calling for the construction of a major oil pipeline. Separate negotiations were ongoing between the White House and top Republicans over policy riders in the year-end spending bill.

After an acrimonious first half of the week, there were growing signs Thursday that a deal was within reach and that leaders were eager to put to an end a bitter year of legislation that has been marked by three near-government shutdowns and fears over a debt default.

“We’ve done enough, Mr. President, back and forth, the Republican leader and me, staking out our positions, and our positions are fairly clear to the American people,” Reid said Thursday morning. “We’re going to try … during the next few hours … to work toward resolving some of the outstanding issues.”

The clear decrease in temperature on Capitol Hill left hope that Congress could adjourn without creating a pre-Christmas crisis.

In remarks at the White House Thursday, Obama also sought to get things moving before the weekend on the payroll tax and government funding bill.

“Congress should not and cannot go on vacation before they have made sure that working families aren’t seeing their taxes go up by $1000,” said Obama, whose own Hawaiian vacation is looming. “There’s no reason the government should shut down over this.”

Reid said he had a productive conversation with Senate Appropriations Chairman Daniel Inouye (D-Hawaii) on Thursday morning and added that there are only a “few issues still outstanding” that are “really small in number.” House Appropriations Chairman Hal Rogers (R-Ky.) told POLITICO that negotiators were “close” to a compromise, saying the end game will become clear at some point Thursday afternoon.

Reid also said it would be a “mistake” for the House to move on its own bill and called for the two chambers to pass a $1 trillion conference report funding a host of federal agencies, saying he expected the Senate was moving Thursday to resolve the remaining concerns.

“We hope that we can come up with something that would get us out of here at a reasonable time in the next few days,” Reid said. “Things are looking up and I’m looking up,” House Appropriations Chairman Hal Rogers (R-Ky.) said of negotiations on the government funding measure.

“We’ve been in useful discussions about how to wrap the session up,” McConnell said. “We hope to be able to pass a combination of appropriation bills and we are working hard to resolve the remaining differences on the payroll tax extension and the related issues that are important to both sides. And we’re confident and optimistic we’ll be able to resolve both on a bipartisan basis.”

Speaker John Boehner (R-Ohio), who is famously calm, matched his Senate counterparts’ calm with his own zen.

“There’s no need to shut down the government, and I see that Senator Reid has already signaled that they may not do that after all,” Boehner said. “Look, I’ve been here for a while. This is not the first time I’ve seen year-end work get knotted up. But I think everyone just needs to step back and take a deep breath. I think there’s an easy way to untangle all of this. We just need to let the members do their job, and we need to let the two institutions do their work.”

Boehner said he hopes congressional appropriators sign off on the spending agreement so it could see a vote before Friday, averting a government shutdown. If they don’t, the speaker said “we’re prepared to move” the components of that agreement as a stand-alone bill.

House GOP leadership is actively weighing sending its members home Friday after voting on a government funding measure, only to bring them back to vote on an extender package when the Senate finalizes its plans.

The shift in mood is significant: Both sides had been positioning to deflect blame for a partial government shutdown. And the two parties have been at loggerheads over conditions for passing a payroll tax holiday. The tax is set to increase by 2 percentage points for millions of workers beginning Jan. 1 if Congress doesn’t act.

Moreover, McConnell and Reid will also have to come up with a package to avert a scheduled pay decrease for Medicare physicians and the expiration of jobless benefits for millions of unemployed workers — and how to pay for them.

Headed into a party lunch, McConnell continued to sound an optimistic note.

“We’re all talking and that’s a good sign,” he said.

At a private meeting Wednesday night, sources said, Boehner said the House has passed its bill on the payroll tax cut, and that it’s now up to McConnell and Reid to determine the Senate’s next steps..

House leaders have not made a final decision to move on their own spending package, but doing so could provoke a fight with the White House over a series of riders targeting several administration policies, including those involving Cuba travel and financial services.

“Well I hope they have the votes for it,” House Minority Leader Nancy Pelosi (D-Calif.) said of the Republicans’ spending plan. “Because if they don’t, they won’t be getting any cooperation from us.”

She added that House Democrats would vote against funding the government if the White House objects to its provisions or threatens a veto.

House Republicans will meet Thursday to be briefed by Appropriations Committee Chairman Hal Rogers (R-Ky.) and the party leadership. The afternoon meeting is going to be key to determining whether progress can be made. GOP leadership knows it faces an uphill climb to pass a short-term government funding measure, and the temperature of the conference and what its members can stomach could be the groundwork for forward movement.