In a rare late-night session, the Senate gave final approval to an ambitious budget and debt deal early Friday, sending it to President Barack Obama to sign.

The final vote on passage was 64-35, as Democrats joined forces with Republican defense hawks over the objections of GOP presidential candidates Ted Cruz, Rand Paul, and Marco Rubio, all of whom voted against the deal. The bill is aimed at averting a debt default, avoiding a partial government shutdown and setting spending priorities for the next two years.

Earlier in Friday's session, the Senate voted 63-35 to end debate on the measure. The vote to approve the bill was taken just after 3 a.m. EDT.

Obama negotiated the accord with Republican and Democratic leaders who were intent on steering Congress away from the brinkmanship and shutdown threats that have haunted lawmakers for years. Former Speaker John Boehner, R-Ohio, felt a particular urgency days before leaving Congress, while lawmakers looked ahead to presidential and congressional elections next year.

Opposition was strong in the Senate, with Paul and Cruz both leaving the campaign trail to criticize the deal as excessive Washington spending.

More On This...

In an hour-long speech that delayed the start of the final vote, Paul said Congress is "bad with money." He railed against increases in defense dollars supported by Republicans and domestic programs supported by Democrats.

"These are the two parties getting together in an unholy alliance and spending us into oblivion," Paul said.

Meanwhile, Cruz said the Republican majorities had given Obama a "diamond-encrusted, glow-in-the-dark Amex card" for government spending.

"It's a pretty nifty card," Cruz said. "You don't have to pay for it, you get to spend it and it's somebody else's problem."

The Democratic National Committee slammed Cruz, Paul and Rubio for their opposition to the deal, with chair Debbie Wasserman Schultz saying, "There is nothing presidential about failing to pay your bills and jeopardizing our standing in the world economy. It is completely unbelievable that these reckless politicians think they deserve a promotion to the presidency."

The agreement would raise the government debt ceiling until March 2017, removing the threat of an unprecedented national default Nov. 3. At the same time, it would set the budget of the government through the 2016 and 2017 fiscal years and ease spending caps by providing $80 billion more for military and domestic programs, paid for with a hodgepodge of spending cuts and revenue increases touching areas from tax compliance to spectrum auctions.

The deal would also avert a looming shortfall in the Social Security disability trust fund that threatened to slash benefits, and head off an unprecedented increase in Medicare premiums for outpatient care for about 15 million beneficiaries.

The promise of more money for the military ensured support from defense hawks like Sen. John McCain, R-Ariz., chairman of the Armed Services Committee, while additional funds for domestic programs pleased Democrats.

Obama and allies like House Minority Leader Nancy Pelosi, D-Calif., were big winners in the talks, but GOP leaders cleared away political land mines confronting the party on the eve of 2016 campaigns to win back the White House and maintain its grip on the Senate.

The measure leaves a clean slate for new Speaker Paul Ryan, R-Wis., as he begins his leadership of the House.

Obama had repeatedly said he would not negotiate budget concessions in exchange for increasing the debt limit, though he did agree to package the debt and budget provisions.

"I am as frustrated by the refusal of this administration to even engage on this (debt limit) issue," said Senate Finance Committee Chairman Orrin Hatch, R-Utah. "However, the president's refusal to be reasonable and do his job when it comes to our debt is no excuse for Congress failing to do its job and prevent a default."

The budget relief would lift caps on the appropriated spending passed by Congress each year by $50 billion in 2016 and $30 billion in 2017, evenly divided between defense and domestic. Another $16 billion or so would come each year in the form of inflated war spending, evenly split between the Defense and State departments.

The Appropriations committees will still have to write legislation to reflect the spending and Congress faces a Dec. 11 deadline to approve such a bill.

The cuts include curbs on Medicare payments for outpatient services provided by certain hospitals and an extension of a 2-percentage-point cut in Medicare payments to doctors through the end of a 10-year budget. There's also a drawdown from the Strategic Petroleum Reserve, and savings reaped from a Justice Department fund for crime victims that involves assets seized from criminals.

Fox News' Kara Rowland and Jason Donner and the Associated Press contributed to this report.