WASHINGTON — Congress on Wednesday voted overwhelmingly to override a veto by President Obama for the first time, passing into law a bill that would allow the families of those killed in the Sept. 11, 2001, terrorist attacks to sue Saudi Arabia for any role in the plot.

Democrats in large numbers joined with Republicans to deliver a remarkable rebuke to the president. The 97-to-1 vote in the Senate and the 348-to-77 vote in the House displayed the enduring power of the Sept. 11 families in Washington and the diminishing influence here of the Saudi government.

The new law, enacted over the fierce objections of the White House, immediately alters the legal landscape. American courts could seize Saudi assets to pay for any judgment obtained by the Sept. 11 families, while Saudi officials have warned they might need to sell off hundreds of billions of dollars in holdings in the United States to avoid such an outcome.

The override comes at an already freighted moment in America’s relations with the kingdom. The Saudi government has vigorously denied that it had any part in the Sept. 11 attacks, and the commission investigating the plot found “no evidence that the Saudi government as an institution or senior Saudi officials individually funded” Al Qaeda, the terror group that carried out the attacks. But the commission left open the possibility that some Saudi officials may have played roles.