The bill, already cleared by the House, now goes to President Barack Obama, who is expected to sign it. The vote was 64 to 35.
The measure, which suspends the nation's debt limit through March 2017 and increases federal spending for domestic and defense programs by more than $80 billion over the next two years, had broad support from Democrats but limited support from Republicans, many of whom complained the deal, brokered by bipartisan congressional leaders, contained too much spending.
GOP presidential candidate Sen. Rand Paul of Kentucky forced a rare overnight Senate session when he filibustered the bill.
"The right's going to get more military money, the left's going to get more welfare money. The secret handshake goes on, and the American public gets stuck with the bill," he said in a speech on the floor Thursday afternoon. "This deal will do nothing but explode the debt."
Sen. Pat Toomey, a conservative Republican facing a tough re-election campaign in Pennsylvania, said the bill "fails to address our overspending problem." Texas Sen. Ted Cruz, who helped force the last government shutdown in 2013, said the deal gives Obama a "diamond-encrusted, glow-in-the-dark AmEx card."
"And it has a special feature," Cruz continued. "The President gets to spend it now, and they don't even send him the bill. They send the bill to your kids and my kids. It's a pretty nifty card. You don't have to pay for it. You get to spend it and it's somebody else's problem."
Other Republicans -- including those who work regularly across the aisle -- complained too.
"The agreement reached by the White House and congressional leaders is yet another example of what the American people hate about Washington," said Sen. Bob Corker of Tennessee, who criticized the deal for relying on budget "gimmicks."
The concerns by Senate Republicans were consistent with those of House Republicans, most of whom voted against the deal when it passed the House on Wednesday. But it was never really in doubt that Senate Republicans, led by their leadership, would provide enough votes to clear the Senate to ensure the U.S. would not default on its debt.
Democrats insisted the agreement was worthwhile.
"The budget agreement is good for the middle class, good for the economy, and good for the country," said Senate Democratic Leader Harry Reid, who worked quietly with bipartisan leaders in the House and Senate to cut the deal.
And Obama said Friday morning that he applauded both parties for the bill's passage.
"It is paid for in a responsible, balanced way -- in part with a measure to ensure that partnerships like hedge funds pay what they owe in taxes just like everybody else. It locks in two years of funding and should help break the cycle of shutdowns and manufactured crises that have harmed our economy," Obama said in a statement.
The vote came hours after former House Speaker John Boehner retired and turned over the top House position to Rep. Paul Ryan, R-Wisconsin.
Passage of the bill means Ryan can begin his new job with a slate cleaned of some of the most controversial issues before the Congress.