The House and Senate voted Wednesday to override President Obama’s veto of a bill that will allow families of 9/11 victims to sue the government of Saudi Arabia.

Senators overrode the veto in a 97-1 vote. Senate Minority Leader Harry Reid, D-Nevada, was the only one in the upper chamber to oppose the override.

The House overrode the veto in a 348-77 vote later in the day.

Get Breaking News Delivered to Your Inbox

This marks the first time Congress has successfully overridden a veto from Mr. Obama. He has vetoed 12 pieces of legislation and Congress has unsuccessfully tried to override five of them.

Aboard Air Force One, White House spokesman Josh Earnest lambasted the Senate, saying it is the single most embarrassing thing the Senate has done in decades.

President Obama slammed Congresss during a taped townhall with CNN in the late afternoon that will air in the evening.

“I think it was a mistake and I understand why it happened,” he said. “What this legislation did was it said if a private citizen believes that having been victimized by terrorism that another country didn’t do enough to stop one of its citizens, for example, in engaging in terrorism, then they can file a personal lawsuit, a private lawsuit in court.”

The votes come after Mr. Obama vetoed the legislation on Friday. The president has argued that the Justice Against Sponsors of Terrorism Act (JASTA) could present consequences in which it could, for example, allow people in other countries to sue the U.S.

In a last-minute attempt to explain the administration’s position, President Obama sent a letter to Reid that said the measure would harm the U.S. and wouldn’t protect Americans against terrorist attacks or improve the effectiveness of the government’s response to attacks.

“Doing so would instead threaten to erode sovereign immunity principles that protect the United States, including our U.S. Armed Force and other officials, overseas,” the president wrote. “This is why I vetoed the bill and why I believe you should vote to sustain that veto.”

The president warned that the bill “could be devastating” to the U.S. military and its service members and would lead to service members, diplomats and intelligence officials finding themselves subject to lawsuits in foreign courts.

“Such lawsuits could subject the United States and its officials to intrusive and time-consuming discovery, including demands from foreign litigants and courts for sensitive U.S. Government information or intelligence,” the president wrote. “Such lawsuits could also lead to sizeable money damages and efforts to attach U.S. Government property to satisfy those judgments -- efforts to which we would be particularly vulnerable given our substantial worldwide presence.”

Before the Senate vote Wednesday, CIA Director John Brennan blasted out a statement warning that the legislation “will have grave implications for the national security of the United States.”

“The most damaging consequence would be for those US Government officials who dutifully work overseas on behalf of our country,” he said. “The principle of sovereign immunity protects US officials every day, and is rooted in reciprocity. If we fail to uphold this standard for other countries, we place our own nation’s officials in danger. No country has more to lose from undermining that principle than the United States—and few institutions would be at greater risk than CIA.”

In May, the Senate passed the measure by voice vote, and it had broad bipartisan support. The measure was sponsored by Sens. John Cornyn, R-Texas, and Chuck Schumer, D-New York, who rarely share the same view on legislation. The House unanimously approved the bill earlier this month.