Setting up a potential override by Congress, Barack Obama vetoed a bill Friday that would have allowed the families of 9/11 victims to sue the government of Saudi Arabia.

Obama cited the potential for the popular bipartisan bill to backfire against the US, its diplomats and military personnel.

The bill sailed through both chambers of Congress by voice vote, with final House passage coming just two days before Obama led the country in marking the 15th anniversary of the attacks that killed nearly 3,000 people in New York, Washington and Pennsylvania on 11 September 2001.

Congress was expected to move rapidly to try to override the veto, which requires a two-thirds vote in the House and Senate. A successful override would be the first of Obama’s presidency. With lawmakers eager to return home to campaign ahead of the November election, a vote could come as early as Tuesday.

Senate majority leader Mitch McConnell’s office said the Senate would take up the override “as soon as practicable in this work period”.

Obama, in a statement accompanying his veto message, said he had “deep sympathy” for the 9/11 families and their desire to see justice for their relatives. But he said the bill would be “detrimental to US national interests” and could lead to lawsuits against the US or American officials for actions taken by groups armed, trained or supported by the US.

“If any of these litigants were to win judgments – based on foreign domestic laws as applied by foreign courts – they would begin to look to the assets of the US. government held abroad to satisfy those judgments, with potentially serious financial consequences for the United States,” Obama said.

But Senator Chuck Schumer of New York, one of the most prominent Democrats urging Obama to sign the bill, predicted Obama’s veto would be “swiftly and soundly overturned in Congress”.

“The families of the victims of 9/11 deserve their day in court, and justice for those families shouldn’t be thrown overboard because of diplomatic concerns,” Schumer said.

Fifteen of the 19 men who carried out the attacks were Saudi nationals. Families of the victims spent years lobbying lawmakers for the right to sue the kingdom in US court for any role elements of Saudi Arabia’s government may have had in the attacks. Saudi Arabia, a key US ally in the Middle East, strongly objected to the bill.

Obama long had objected, too, warning that if US citizens are allowed to take the Saudis into court, then foreign countries could do the same to the United States, its diplomats and its service members. The administration was also apprehensive about undermining a longstanding yet difficult relationship with Saudi Arabia. The US relies on the Saudis as a counter to Iran’s influence in the region as well as to help combat the spread of terrorism throughout the Middle East.

After the bill passed, proponents said they were confident they had the backing needed to overturn Obama’s veto. But the administration has lobbied aggressively since then in an attempt to persuade lawmakers to withdraw support for the bill and found some members who were sympathetic to Obama’s arguments.

It was unclear whether the White House had peeled off enough votes to avert a veto override, which would be a major defeat for the president.

The bill’s proponents disputed arguments of a boomerang effect if the measure were to become law. Another sponsor, Republican representative Peter King of New York, said foreign governments cannot look the other way if terrorist activities are being plotted or launched from inside their borders.

The support group 9/11 Families United For Justice Against Terrorism also dismissed fears that the US could become the target of reciprocal lawsuits.

In the run-up to Obama’s veto, the White House said the system the US uses to identify and punish countries that support terrorism was set by law and is more effective than a “patchwork” of legal decisions.

The bill, the Justice Against Sponsors of Terrorism Act, had triggered a threat from Saudi Arabia to pull billions of dollars from the US economy if it was enacted. But Saudi foreign minister Adel bin Ahmed Al-Jubeir denied in May that the kingdom made any threats over the bill. He said his country had warned that investor confidence in the US would shrink if the bill became law.

The House vote on 9 September came two months after Congress released 28 declassified pages from a congressional report into 9/11. The pages reignited speculation over links that at least a few of the attackers had to Saudis, including government officials. The allegations were never substantiated by later US investigations into the terrorist attacks.

The Senate passed the bill in May.

Brian McGlinchey, director of advocacy for the website 28pages.org, said making the documents public “strengthened the resolve of 9/11 families and other advocates of justice to bring about the enactment” of the bill.

He said a decision by Obama to deny the 9/11 families “their well-deserved day in court would truly stain his legacy”.