US President Barack Obama has said Congress made a "mistake" by overriding his veto and pushing through a bill that allows legal action against Saudi Arabia over the 9/11 attacks.
He said the bill would set a "dangerous precedent" for individuals around the world to sue the US government.
Wednesday's vote was the first time Mr Obama's veto power was overruled.
CIA Director John Brennan agreed that the bill carried "grave implications" for national security.
He added: "The downside is potentially huge."
The Justice Against Sponsors of Terrorism (JASTA) legislation opens the door for victims' families to sue any member of the Saudi government suspected of playing a role in the 9/11 attacks.
Fifteen of the 19 hijackers were Saudi nationals, but the oil-rich kingdom - a key US ally - has denied any role in the attacks, which left nearly 3,000 people dead.
While US intelligence raised suspicions about some of the hijackers' connections, the 9/11 commission found no evidence that senior Saudi officials, or the government as an institution, had funded the attackers.
Almost 3,000 people were killed when they deliberately flew planes they had seized into the World Trade Center and the Pentagon. Another hijacked plane was brought down in a field in Pennsylvania.
Tough politics - Barbara Plett Usher, BBC News, Washington
Mostly this was about showing solidarity with the families of 9/11 victims. Lawmakers across the board said they deserved their day in court, whatever the "diplomatic discomforts" involved in suing a foreign government.
It would have been difficult to be seen to be voting against them, right after the 15th anniversary of the attacks, and just before an election. Even President Obama acknowledged that the politics were tough.
But some Congress people share the families' suspicions of a certain degree of Saudi involvement, even if not at the highest levels of government as concluded by the 9/11 Commission. And they've become more willing to openly question this bedrock Mid-East alliance because of other strains in the relationship, which contributed to the climate in which the vote was held.
The Saudis have lobbied furiously against the bill, outlining in detail the steps they've taken since 2001 to disrupt fundraising for extremists by Islamic charities in the Kingdom, and to establish close counter terrorism cooperation with the US. The administration is worried the latter in particular might be affected by congress' action.
Reacting to the congressional vote on Wednesday, Mr Obama told CNN: "It's a dangerous precedent and it's an example of why sometimes you have to do what's hard.
"And, frankly, I wish Congress here had done what's hard.
"The concern that I've had has nothing to do with Saudi Arabia per se or my sympathy for 9/11 families.
"It has to do with me not wanting a situation where we're suddenly exposed to liabilities for all the work that we're doing all around the world and suddenly finding ourselves subject to private lawsuits."
What cost? - US media wary
"Wouldn't you know that Congress finally challenges President Obama on foreign policy, and it's in a bad cause that will harm US interests. Too bad the president did so little to stop it." - Wall Street Journal
"There is a broader subtext to this legislation. The kingdom can no longer count on the US and - a far more dangerous reality - may no longer even want to. With a single vote, Congress may well have brought down on America a host of plagues many on Capitol Hill may only vaguely appreciate." - CNN
Administration officials said they knew from the start that Obama's veto was unlikely to survive an override vote — the politics surrounding the bill had become so charged that they overwhelmed the more abstract arguments for the importance of respecting foreign sovereign immunity. - The Hill
But families of the victims and their lawyers have dismissed these concerns.
"We rejoice in this triumph and look forward to our day in court and a time when we may finally get more answers regarding who was truly behind the attacks," said Terry Strada, national chair of the 9/11 Families & Survivors United for Justice Against Terrorism.
Saudi media blast Congress vote
Saudi media have criticised the decision of the US Congress to overrule President Barack Obama's veto of legislation allowing families of victims of the 9-11 attacks to sue the Saudi government.
And the Saudi-funded, pan-Arab Al-Arabia TV said: "Saudi Arabia has an arsenal of ways to respond to the Justice Against Sponsors of Terrorism Act (JASTA)".
The pro-government daily Saudi Okaz said in a banner headline: "The Justice Against Sponsors of Terrorism (JASTA) is a law against justice", while the pro-government Saudi daily Al-Jazeera carried a piece by Ahmed al-Farraj criticising the bill as "unfair".
On social media, commentators were critical of the bill, with many users shrugging off its possible effects on Saudi Arabia, whose alleged support for terrorism they said was unproven.
"JASTA poses no threat to Saudi Arabia as it has nothing to do with terrorism. No lawsuit will be filed against Saudi Arabia using JASTA except by resorting to false witnesses," tweeted Khalid Ashaerah (@KHALID_ASHAERAH), a pro-government author of books who has 110,000 followers.
"Probably the greatest defeat for democratic thought achieved by members of the House of Representatives. Almost all neutral experts have agreed that JASTA is detrimental to the US," tweeted Mohamed al-Saidi (@mohamadalsaidi1), a pro-government Saudi professor of Islamic doctrine with 803,201 followers.
Mr Obama suggested that his colleagues' voting patterns were influenced by political concerns.
"If you're perceived as voting against 9/11 families right before an election, not surprisingly, that's a hard vote for people to take.
"But it would have been the right thing to do."
The Senate voted 97-1 and the House of Representatives 348-77, meaning the bill becomes law.
White House spokesman Josh Earnest told reporters the vote was "the single most embarrassing thing the United States Senate has done" in decades.
But the measure's supporters contended the legislation only applies to acts of terrorism that have occurred on US soil - and side-swiped at Mr Obama for his perceived prioritising of relations with Saudi Arabia.
"The White House and the executive branch (are) far more interested in diplomatic considerations," said Democratic New York Senator Chuck Schumer.
"We're more interested in the families and in justice."