The bill passed, 266-167, with nearly unanimous Democratic support. House Republicans were deeply divided by John Boehner's last major act as speaker.

Just 79 Republicans voted in favor of the measure, in line with what leadership was expecting. But 167 voted no.

Congressional leaders and the White House came to tentative terms on the deal in the wee hours of Tuesday morning. The legislation could stave off many of the fiscal land mines remaining through next year's election and beyond.

The agreement, which would set spending levels for two years, comes just days before Congress needed to raise the nation's debt ceiling to prevent a potential default on the country's obligations, according to the Treasury Department. And it comes a little more than a month before another potential government showdown.

The bill suspends the debt ceiling through March 2017. It raises spending levels in equal amounts in defense and nondefense areas and averts a potential government shutdown in December. Those spending increases are offset through other cuts and revenue-generating measures.

Its passage serves as the final act for Boehner (R-Ohio) before he leaves Congress at the end of the week and hands over the role to Rep. Paul Ryan (R-Wisconsin), who was selected as the Republican nominee for speaker on Wednesday.

"President Obama and Speaker Boehner are heading into retirement. Some people get a gold watch. Obama and Boehner are settling for at least $80 billion in additional spending and debt above the budget caps. Unfortunately, our children and grandchildren will be left to foot the bill long after they are gone," presidential candidate and Sen. Ted Cruz (R-Texas) said in part of a lengthy, five-paragraph statement on Tuesday.