The House on Wednesday night passed a bipartisan bill to suspend the debt ceiling, overcoming vocal opposition from conservative and liberal lawmakers and bringing the country one step closer to avoiding an economy-rattling default ahead of next week’s deadline.

The legislation — which was crafted through negotiations between President Biden, Speaker Kevin McCarthy (R-Calif.) and their designees — cleared the chamber in a bipartisan 314-117 vote and now heads to the Senate, where leaders are hoping for swift consideration as the default deadline looms.

Treasury Department Secretary Janet Yellen has warned that the U.S. could no longer be able to pay its bills June 5, a situation that would plunge the country into its first-ever default — which economists and administration officials have warned would be catastrophic for the economy.

“Passing the Fiscal Responsibility Act is a crucial first step for putting America back on track,” McCarthy said on the House floor Wednesday. “It does what is responsible for our children, what is possible in divided government, and what is required by our principles and promises.”

“Yes, it may not include everything we need to do,” he continued, “but it is absolutely what we need to do right now.”

The bill suspends the debt limit through Jan. 1, 2025, while also implementing a slew of cost-cutting measures including new spending caps over the next two years and a clawback of billions of dollars of unspent COVID-19 funds. It also includes permitting reform, puts an end date on Biden’s pause on student loan repayments, beefs up work requirements for federal assistance programs and rescinds funding appropriated to the Internal Revenue Service as part of the Inflation Reduction Act that Democrats passed last summer.

Wednesday’s vote marked a victory for McCarthy, who led his conference in passing a sweeping debt limit bill in April, got Biden to the negotiating table after the president for months insisted on a “clean” debt ceiling increase, and succeeded in narrowing those talks to just him, the president and their appointed deputies. McCarthy’s deputies — Reps. Garret Graves (R-La.) and Patrick McHenry (R-N.C.) — then extracted concessions from the White House, refused proposals such as increasing taxes and worked furiously to sell the ultimate agreement to his conference.

“More than two-thirds of our conference voted for it. We got all the Democrats who signed a discharge petition — to say they would never raise the debt ceiling, only raise it clean — we got them to vote for it too. So think about how much further we can go,” McCarthy said during a press conference following the vote.

But the deal simultaneously heightened the chances that McCarthy — who fought for his Speakership over 15 ballots in January — could face a challenge to his gavel from disgruntled conservatives who felt betrayed by the agreement he struck with the White House.

The vote also notched a win for Biden, who achieved the Democrats’ goal of punting any future debt limit increase beyond the 2024 presidential election.

Both camps, however, saw their fair share of opposition.

Seventy-one Republicans and 46 Democrats voted against the bill in the House — mostly liberals and conservatives protesting specific provisions of the bill. Their numbers, however, were never a threat to the bill’s passage because of a hodgepodge of moderates and leadership allies who — despite some acknowledging the bill wasn’t exactly what they wanted — threw their support behind the measure.

Conservatives, generally speaking, were frustrated with the magnitude of spending cuts in the agreement and the absence of several provisions that were in the debt limit bill — titled the Limit, Save, Grow Act — that House Republicans passed in April. 

The Congressional Budget Office (CBO) Tuesday estimated that the bipartisan debt limit deal could reduce projected deficits by about $1.5 trillion over the next decade, a meager assessment compared to the roughly $4.8 trillion the nonpartisan scorekeeper said the GOP bill would save.

“Trillions and trillions of dollars in debt for crumbs, for a pittance, every single thing,” Rep. Scott Perry (R-Pa.), the chairman of the House Freedom Caucus, said during a press conference Tuesday.

“The Speaker himself has said on numerous occasions the greatest to America is our debt and now is the time to act,” he later added. “We had the time to act and this deal fails, fails completely.”

Ahead of the high-stakes vote, more than 30 Republicans went on the record saying they would not vote for the bill, with some encouraging their GOP colleagues to join them in opposition.

“I want to be very clear: Not one Republican should vote for this deal. Not one,” Rep. Chip Roy (R-Texas) said during a press conference Tuesday. “If you’re out there watching this, every one of my colleagues, I’m gonna be very clear: Not one Republican should vote for this deal.”

“It is a bad deal,” he added.

Liberals, on the other hand, voiced concern with the size and scope of spending cuts in the bill and the provisions included, and accused Republicans of holding the U.S. economy hostage by forcing cost-cutting provisions in conjunction with the debt limit hike.

“We must be clear that this hostage-taking is absolutely unacceptable and that there will be very real consequences for working people and poor people who will now be forced to resume crippling student debt payments, predominantly Black and Brown women who will be kicked off food assistance because they will be forced into working as they enter their senior years, and people everywhere who will be forced to live with more environmental injustice,” Rep. Pramila Jayapal (D-Wash.), the chairwoman of the Congressional Progressive Caucus, said in a statement after voting no on the bill.

Work requirements also emerged as a particularly controversial topic throughout negotiations — McCarthy dubbed them a red line, and House Minority Leader Hakeem Jeffries (D-N.Y.) called them a nonstarter. 

The legislation implements new work requirements for recipients of the Supplemental Nutrition Assistance Program — formerly known as food stamps — who are aged 50 to 54 and do not have dependents, and it includes some additional work requirements for the Temporary Assistance for Needy Families program.

The bill does, however, include food stamp work requirement exemptions for individuals experiencing homelessness, veterans, and those younger than 25 who were in foster care when they turned 18.

The CBO estimated that the work requirement changes would actually increase spending by $2.1 billion over the next 10 years.

The bill came to the floor for a final vote Wednesday after a drama-filled procedural vote that drove Democrats to trigger an emergency effort to help Republicans advance the bill.

While votes on rules, which govern debate over legislation, typically break along party lines, 29 Republicans broke from the GOP and opposed the rule Wednesday as a way to boycott the debt limit bill. Shortly before the vote closed — as the bill was poised to be blocked — 52 Democrats threw their support behind the rule, bringing the final vote to 241-187 and allowing the debt limit bill to advance to the floor for a full vote.

“From the very beginning, House Democrats were clear that we would not allow extreme MAGA Republicans to default on our debt, crash the economy or trigger a job-killing recession. Under the leadership of President Joe Biden, Democrats kept our promise. And we will continue to do what is necessary to put people over politics,” Jeffries said on the House floor Wednesday.

He noted the last-minute scrambling on the bill.

“The question that remains right now is what will the House Republican majority do? It appears that you may have lost control of the floor of the House of Representatives. Earlier today, 29 House Republicans voted to default on our nation’s debt and against an agreement that you negotiated,” Jeffries said. “It’s an extraordinary act that indicates just the nature of the extremism that is out of control on the other side of the aisle.”

House passage of the Biden-McCarthy deal puts Congress closer to capping off a months-long saga over the debt ceiling, which began when the nation hit its borrowing limit Jan. 19, forcing the Treasury Department to begin implementing extraordinary measures so the country could continue paying its bills and stave off a default.

And it changes the political dynamics in the House GOP for McCarthy. 

McCarthy in January had made concessions and commitments on House rules and spending in order to secure the Speakership. The various factions of the conference had generally gotten along in the months since, but the right flank’s disappointment in the debt limit deal shattered that.

Rep. Dan Bishop (R-N.C.) even called for a vote to oust McCarthy as Speaker – though he did not commit to making that move.

Allies of McCarthy hope that the discontent will blow over. 

“I think you’ll see that there’s still a broad cross-section of this conference that wants to try to figure out a way to do things together,” Rep. Dusty Johnson (R-S.D.) said.

McCarthy, for his part, is brushing aside the looming threat.

“Everybody has the ability to do what they want. But if you think I’m gonna wake up in the morning and be ever worried about that?” he told reporters Wednesday. “No, doesn’t bother me.”

Emily Brooks and Mike Lillis contributed. Updated at 11:18 p.m. EDT