Congress on Wednesday moved a step closer to clearing a bipartisan budget deal that would boost spending for domestic and defense programs over two years while suspending the debt limit into 2017.

The House passed the bill on a 266 to 167 vote late Wednesday afternoon and Senate leaders have promised to quickly move it through the upper chamber. Senate leaders want to move the bill quickly — the Treasury Department estimates the deadline for raising the debt ceiling is Nov. 3 — and sought to start the procedural ball rolling on Wednesday night, with the aim of it hitting the floor this week.

The agreement would essentially end the often contentious budget battles between congressional Republicans and President Obama by pushing the next round of fiscal decision making past the 2016 election when there will be a new Congress and White House occupant.

House Republican leaders unveiled the proposal earlier this week and immediately faced challenges from conservatives upset over both the secretive negotiations that led to the agreement as well as the policies contained in the bill.

Some of this discontent was dealt with after a change was made to the bill late Tuesday night to ensure that the full cost of the $80 billion in new discretionary spending was offset by an equal amount of mandatory spending cuts and increased revenue.

Several Republicans raised concerns  that the bill fell about $4 billion short of this goal, but the Congressional Budget Office on Wednesday reported that the changes to the legislation had closed this gap.

Senior Republicans came forward ahead of the vote to support the legislation and encourage others to join them. House Armed Services Committee Chairman Mac Thornberry (R-Texas) said the bill would benefit the military and prevent the threat of another shutdown.

“It stops the cuts in defense, it increases the money going to our troops and it prevents them from being used as a bargaining chip in the future,” Thornberry said. “I think that is the sort of stability and predictability they need and that they deserve.”

Still, many House Republicans remained opposed to the deal and only 79 voted for it while 187  Democrats supported the bill.

The agreement would lift the so-called sequester spending caps to increase discretionary spending by about $80 billion over two years, an amount that would be split equally among defense and domestic programs. To offset this cost, negotiators tapped a number of sources, including by making changes to Medicare and Social Security, auctioning off spectrum controlled by the government, selling crude oil from the Strategic Petroleum Reserve and tightening tax rules for business partnerships.

In addition, the legislation would limit a historic premium increase for some Medicare Part B beneficiaries set to go into effect next year for services like hospital care and doctor visits. The agreement also would prevent a potential 20 percent across-the-board cut to Social Security Disability Insurance benefits that is also set to take place next year, by transferring some funding from the main Social Security fund and making changes to the program. These cost-saving changes include allowing some recipients who can still work to receive partial payments while earning outside income and expanding a program requiring a second medical expert to weigh in on whether an applicant is truly disabled.

Presidential candidate Sen. Rand Paul (R-Ky.) said Tuesday that he plans to filibuster the bill, but the possibility of slowing down passage is limited.

The agreement will have to clear one procedural hurdle with at least 60 votes before it can be approved by a simple majority. At most, Paul could briefly delay the final vote by refusing to allow leaders to cut off debate before the maximum 30 hours allowed under Senate rules have expired.

The deal to do away with two of the thorniest issues facing Republicans — setting spending levels and raising the debt ceiling — comes as the House GOP on Wednesday nominated Rep. Paul D. Ryan (R-Wis.) to replace John Boehner (R-Ohio) as speaker of the House. Boehner is resigning from Congress this week.

The full House will vote Thursday to elect a new speaker and Ryan is expected to easily win the gavel.

Ryan said Wednesday morning that he  supports the budget deal.

“As with any budget agreement, this one has some good, some bad, and some ugly. It does include meaningful reforms to strengthen our safety net programs, including significant changes to bolster Social Security. It would allow us to return to regular order in our budget process,” he said in a statement. “What has been produced will go a long way toward relieving the uncertainty hanging over us, and that’s why I intend to support it.”

Ryan is said to have not been involved in the budget negotiations, which were worked out between the White House and Boehner, House Minority Leader Nancy Pelosi (D-Calif.), Senate Majority Leader Mitch McConnell (R-Ky.) and Senate Minority Leader Harry Reid (D-Nev.). On Tuesday, Ryan strongly condemned the way the deal was assembled.

“About the process, I can say this: I think the process stinks,” Ryan said.

Democrats pushed back against claims that Ryan was kept out of the negotiations. A senior Democratic aide said that Ryan’s staff was involved in drafting Social Security Disability program changes and the Medicare portion of the bill

But Ways and Means Committee staff wrote many of the reforms earlier in the year as part of an overall effort by Ryan to reform the ailing disability plan, which was expected to run dry next year. Leaders drew on those proposals and incorporated the material into budget negotiations.

What would be cut and what would be kept in outgoing House Speaker John Boehner's plan to raise the debt ceiling (Sarah Parnass/The Washington Post)

While the changes made to ensure the bill would not add the deficit eased the concerns of some House members, it did little to win the support of the group of about 40 hard-line conservatives who have so often been at odds with Boehner. The House Freedom Caucus on Wednesday said it “strongly” opposed the bill, arguing it was drafted behind closed doors by leaders and is bad policy.

“This deal is an affront to open, accountable, and limited government,” the group said in a statement. “It plunges our nation into debt to the tune of nearly $20 trillion, busts the spending caps enacted by Congress just a few years ago, perpetuates our looming entitlement crisis by pilfering money from Social Security, and contains budget and accounting gimmicks that are manifestly fraudulent.”

But leaders expected that the Freedom Caucus members would never support the bill and were confident that Democrats and moderate Republicans could work together to pass the bill.

Another fire was put out Wednesday when leaders agreed to in the future rollback a provision in the bill regarding crop insurance that would produce $3 billion in saving over 10 years.

Members of the House and Senate Agriculture committees were angry over the provision, arguing they made carefully considered changes to this program in the most recent Farm Bill and were not consulted about the language in the budget deal.

On Wednesday, they announced leadership had promised them the crop insurance language would be reversed in an upcoming spending bill.

The budget deal sets the overall discretionary spending level and it will now be up to the House and Senate Appropriations committees to produce legislation parceling out the funds to the various federal agencies and programs.

There is still a chance for discord in the process.

On Wednesday, the White House released a policy statement endorsing the bill but warning lawmakers against attaching controversial policy language to the appropriations bill that will be produced later this year.

House Appropriations Committee Chairman Harold Rogers (R-Ky.) struck an optimistic note, saying in a floor speech that the agreement gives his panel the chance to have a discussion over how the government should distribute funding now that the debate over how much should be spent is settled.

“That’s why I’m so strong for this bill,” Rogers said. “For me the two years we have now to get back on regular order and stop lurching from crisis to crisis, to stop that business, this bill will give us that great chance.”