Barack Obama says Congress is making a "mistake" and setting "a dangerous precedent" by passing a bill that would allow families of 9/11 victims to sue the Saudi government for damages.
Both the Senate and the House of Representatives voted by an overwhelming majority to override the President's veto of the Justice Against Sponsors of Terrorism Act (JASTA).
The votes on Wednesday afternoon were the first time in the whole of Mr Obama's presidency that he has been overruled by Congress.
And speaking on CNN in the wake of the decision, Mr Obama warned that it left the US exposed to lawsuits from people around the world who have been affected by American foreign policy.
The law will grant an exception to the legal principle of sovereign immunity in cases of terrorism on US soil.
"It's a dangerous precedent and it's an example of why sometimes you have to do what's hard," he said. "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."
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."
John Brennan, director of the CIA, agreed with Mr Obama that the bill carries "grave implications" for US national security.
"The downside is potentially huge," he said.
The House of Representatives voted 348-77 against the veto, hours after the Senate rejected it 97-1, meaning the JASTA will become law.
"Overriding a presidential veto is something we don't take lightly, but it was important in this case that the families of the victims of 9/11 be allowed to pursue justice, even if that pursuit causes some diplomatic discomforts," Senator Charles Schumer, a top Senate Democrat, said in a statement.
Schumer represents New York, site of the World Trade Center and home to many of the nearly 3,000 people killed in the 2001 attacks, survivors and families of victims.
Family members had campaigned for the bill to coincide with the 15th anniversary of the attacks this month, and on Wednesday two fire trucks displayed a giant American flag outside the Senate. The Saudi government financed an extensive lobbying campaign against the new law.
"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," Terry Strada, whose husband died in the attacks, said in a statement.
Secretary of Defense Ash Carter and General Joseph Dunford, chairman of the joint chiefs of staff, also opposed the bill on grounds of national security.
But the controversy over the bill may not be finished quite yet. At least 28 senators signed a letter to JASTA's sponsors, Schumer and Republican Senator John Cornyn, asking that they work with them to mitigate any potential unintended national security and foreign policy consequences.
Additional reporting by agencies
Join our commenting forum
Join thought-provoking conversations, follow other Independent readers and see their replies