It passed 65-34.
Passage comes just a day before funding authority for ongoing road projects runs out.
However, because of disagreements with the House about how the Senate bill is paid for, a short-term funding bill will need to clear the Senate later Thursday and be sent to President Barack Obama for his signature.
That will keep road projects humming through the fall and allow House and Senate additional time to resolve their differences.
"Many thought we'd never get here, but we have," said a pleased Senate Majority Leader Mitch McConnell following the vote.
About a week ago, McConnell reached an agreement on the long-term spending plan that many didn't think was possible with Sen. Barbara Boxer of California, the retiring liberal Democrat.
The bill authorizes infrastructure projects for six years but only officially funds them through three, ensuring that lawmakers will have to come back at that time to come up with the remaining funding. It's a flaw in the bill cited by its critics in the House.
The Senate bill is paid for through a variety of means, including the sale of oil from the government-owned Strategic Petroleum Reserve. But it does not raise the taxes consumers pay on gas at the pumps, a non-starter for nearly all Republicans and the principal obstacle for years to passing a long-term bill.
Sen. James Inhofe of Oklahoma, the conservative chairman of Environment and Public Works Committee, quipped about working with Boxer, who is the top Democrat on the committee.
"She is a very proud liberal and I'm a very proud conservative. And what do we have in common? This bill that's about it," Inhofe said. "Then we go back to fighting again."