The final vote was 97-1 against the veto. Democratic Minority Leader Harry Reid was the lone "no" vote.
Democratic Senator Tim Kaine, Hillary Clinton's vice presidential running mate, and Bernie Sanders, an independent who caucuses with Democrats and is a former White House contender, did not vote.
The measure next goes to the House of Representatives, which was due to vote later on Wednesday. If two-thirds of House members also support the "Justice Against Sponsors of Terrorism Act," it would be the first veto override of Obama's eight-year presidency.
The Saudi government, a frequent U.S. partner in the Middle East, strongly opposed the bill, known as JASTA.
Obama had argued that the legislation could expose U.S. companies, troops and officials to lawsuits, and alienate important allies at a time of global unrest.