The west front of the U.S. Capitol is seen under repair Sept. 2, 2015 in Washington. Congress returns on Sept. 8 with a critical need for a characteristic that has been rare through a contentious spring and summer _ cooperation between Republicans and President Barack Obama. Lawmakers face a weighty list of unfinished business and looming deadlines, with a stopgap spending bill to keep the government open on Oct. 1 paramount. (AP Photo/Alex Brandon)

WASHINGTON (AP) — Just hours before a midnight deadline, a bitterly divided Congress approved a stopgap spending bill Wednesday to keep the federal government open — but with no assurance there won’t be yet another shutdown showdown in December.

Democrats helped beleaguered House Republican leaders pass the measure by 277-151 — a lopsided vote shrouding deep disagreements within the GOP — after the Senate approved it by a 78-20 tally earlier in the day. The votes sent the bill to President Barack Obama for his signature.

Approval of such stopgap measures used to be routine, but debate this year exposed acrimonious divisions between pragmatic Republicans such as House Speaker John Boehner and more junior lawmakers in the party’s tea party wing who are less inclined to compromise. The tea partyers had demanded that the must-pass measure be used to punish Planned Parenthood, stripping it of federal money because of its practice of supplying tissue from aborted fetuses for scientific research.

House Republicans opposed the measure by a clear margin, but Democratic support was unanimous.

The legislation finances the government through Dec. 11, providing 10 weeks to negotiate a more wide-ranging budget deal that would carry past the 2016 presidential election. But the talks promise to be difficult, and success is not assured.

Boehner is resigning from Congress at the end of October, a decision he announced last week after informing Republicans he would not risk a government shutdown over Planned Parenthood.

A similar fight over implementing Obama’s health care law sparked a 16-day shutdown two years ago that Boehner, Senate Majority Leader Mitch McConnell of Kentucky and other top Republicans did not want to repeat in election season. McConnell is seeking to protect embattled incumbents in Democratic-leaning states such as Wisconsin and Pennsylvania, while some GOP conservatives are more apt to use the battle to appeal to the party’s core voters on the right.

“Today was a win for the Washington cartel, and another setback for the American people,” said Rep. Ted Cruz, R-Texas, who is using combat with Washington GOP leaders to help define his presidential campaign. “Republican leadership chose to abandon its constitutional power of the purse and to fund 100 percent of President Obama’s failed agenda.”

Support from Democrats also helped power the measure through the Senate, all of the opposition coming from conservative Republicans.

Longtime lawmakers bemoaned the chronic dysfunction on Capitol Hill and the collapse of the annual appropriations process that is supposed to be wrapped up by now. Democrats demanding a new budget deal have blocked work in the Senate, while a fight over the Confederate flag halted work in the House with only six of the 12 annual spending bills having passed.

“It is to my great dismay that we are at this point again, requiring a temporary Band-Aid to buy us time to do our duty,” said Rep. Hal Rogers, R-Ky., chairman of the Appropriations Committee, during House debate.

Tea party anger directed at Boehner over the Planned Parenthood issue helped prod the Ohio Republican’s announcement to step down. His decision — and other House leadership races — have highlighted divisions between more pragmatic Republicans and hardline conservative wing that is increasingly prominent in Congress, especially in the rough-and-tumble House.

McConnell said Tuesday that he and Boehner spoke with Obama recently and that he expects budget negotiations to get underway soon. The turmoil in the House, where many conservatives want to block spending increases, is certain to complicate the talks, which are likely to focus on swapping near-term budget increases for the Pentagon and domestic programs for longer-term saving elsewhere in the budget.

Majority Leader Kevin McCarthy, R-Calif., the likely new House speaker, hasn’t said whether he supports a deal.

The Pentagon and domestic agencies all are still operating under automatic curbs that would effectively freeze their spending at current levels. Republicans are leading the drive to boost defense while Obama is demanding equal relief for domestic programs.

The conversation among McConnell, Boehner and Obama took place in mid-September — before Boehner announced he was stepping down. Many of the conservative GOP lawmakers who helped bring Boehner down want to preserve stringent “caps” on the spending bills Congress passes every year. But Senate Republicans are generally more eager to rework the 2011 Budget Control Act that put them in place.

“We have to stop devastating sequester cuts from hitting our military and middle class, even the Republican leader agrees,” said top Senate Democrat Harry Reid of Nevada. “Because a week or 10 days ago he said ‘We are inevitably going to end up in negotiations that that will crack the Budget Control Act once again. I say ‘hallelujah.’”

Eight of the 20 Republican senators who opposed Wednesday’s bill are up for re-election in states carried by Mitt Romney in 2012. Presidential aspirants Lindsey Graham of South Carolina and Marco Rubio of Florida skipped the vote.

Republicans have long targeted Planned Parenthood, and the group’s top official defended it in congressional testimony on Tuesday.

Republicans say that videos made by abortion foes show Planned Parenthood has broken federal laws including a ban on for-profit fetal tissue sales. The organization says it has acted legally and the videos were deceptively edited.