WASHINGTON — Just before midnight on Monday, congressional lawmakers and the White House tentatively agreed on a major budget deal that would end such standoffs in the Obama presidency and solve a potentially catastrophic debt default coming within days.

Several aides said that, absent last-minute drama, it could be voted on by the House as early as Wednesday and by the Senate a day later. That would place it on the docket at roughly the same time that House lawmakers vote on Rep. Paul Ryan (R-Wis.) as their new speaker.

“Patience is a virtue,” said one congressional source, when asked about the timing of the deal. “We are still on track.”

Under the arrangement detailed by congressional aides, the debt limit, predicted to be hit onNov. 3, would be extended into March 2017 — well into the next president’s term.

Additionally, over the next two years, government spending would rise $80 billion above the caps that sequestration currently allows. That money would be doled out evenly between defense and non-defense accounts, with $50 billion budgeted for the first year and $30 billion for the second.

On top of that, the bill would include $32 billion for the overseas contingency fund — a veritable piggybank for administrations to cover the costs of wars — split over the next two years. That would bring the deal’s total spending increase to $112 billion over two years.

A congressional aide noted that these spending levels are far greater than the $63 billion from two years of sequestration relief passed during the last deal hammered out by Rep. Ryan and Sen. Patty Murrary (D-Wash.) at the end of 2013. Unlike that deal, this one has been negotiated largely in secret between top leaders from each chamber.

“The president has repeatedly called on Congress to pass a budget that lifts harmful spending cuts known as sequestration and that invests in both our economic security and national security.  The agreement reached by Congressional leaders last night meets these key tests,” said a White House official. “While this agreement is indeed a compromise, it is promising that Democrats and Republicans in Congress were able to come together to reach a strong agreement that would break the cycle of short-sighted, crisis-driven decision-making. We urge members of Congress from both parties to take the next step and pass a budget based on this agreement.”