Congress has voted to override the president’s veto for the first time in his administration over a controversial piece of legislation that would allow the families of the victims of the 9/11 attacks to sue Saudi Arabia for any role in the plot.

The overwhelming 97-1 vote in the Senate and 348 -77 vote in the House comes after Obama vetoed the bill on Friday and a consequent push by 9/11 survivors, victims' family members and their supporters to buck the president. A two-thirds vote in each chamber was required to pass the bill over the president’s objections.

All of the senators voted in favor of the legislation except for Senate Minority Leader Harry Reid of Nevada who had previously discussed the matter with the administration. In the House, 59 Democrats and 18 Republicans voted against it.

Related: Obama Vetoes Bill to Let 9/11 Families Sue Saudi Arabia

Democratic Sen. Charles Schumer of New York, a co-sponsor of the bill, said in a statement after the Senate vote, "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."

"This measure does not prejudge a verdict or issue a judgement. It gives both sides a fair day in court," said Democratic Sen. Richard Blumenthal of Connecticut during remarks on the Senate floor, arguing the legislation simply closed a loophole. “If the Saudi government had no involvement in 9/11, it has nothing to fear. But if it was culpable then it should be held accountable.”

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

Wednesday’s vote put Senate Democrats in somewhat of an awkward position in that even though they backed the initial bill, they had a hand in setting up the first override of the commander-in-chief.

But with an election around the corner and recent bombings in New York and New Jersey, there was mounting pressure to support 9/11 families over the president, especially because the vote was a formal roll call.

The measure, the Justice Against Sponsors of Terrorism Act, initially passed unanimously in both chambers of Congress earlier this year.

Related: House OKs Bill to Let 9/11 Families Sue Saudi Arabia

The bill would allow families of 9/11 victims to sue Saudi Arabia if the country is found legally liable for helping support the terror attacks. Fifteen of the 19 terrorists were Saudi, although the country’s leaders have denied any involvement and have come out against the legislation.

The White House is against the legislation and has cited concerns that it could open the U.S. to a slew of similar lawsuits. Officials have also argued the measure could result in Americans and U.S. service members facing litigation in places like Iraq or Afghanistan. After the upper chamber of Congress' vote, White House spokesman Josh Earnest called the action "the single most embarrassing thing the Senate has done since 1983."

Terry Strada, who helps head the 9/11 Families & Survivors United for Justice Against Terrorism, disagreed.

"How petty can you be? This was Congress at its best. This was democracy at its best," said Strada whose husband died during the 9/11 attacks. "Embarrassing? I think it was much more embarrassing that the president decided to veto the bill in the first place."

In explaining the veto on Friday, Obama said he has "deep sympathy" for the families and desire for justice.

But he added the legislation would "invite consequential decisions to be made based upon incomplete information and risk having different courts reaching different conclusions about the culpability of individual foreign governments and their role in terrorist activities directed against the United States — which is neither an effective nor a coordinated way for us to respond to indications that a foreign government might have been behind a terrorist attack."

CIA Director John Brennan released a statement on Wednesday also opposing the bill.

"The most damaging consequence would be for those U.S. Government officials who dutifully work overseas on behalf of our country," he said in the statement. "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."

Before the vote, Republican Sen. Bob Corker of Tennessee repeated concerns on the Senate floor that the bill could expose the U.S. to enormous liability, adding a better solution would have been to set up some type of tribunal. But the chairman of the Senate Committee on Foreign Relations said in order to be consistent and to give the victims an outlet to seek justice, he would back the legislation.

"There could be unintended consequences that work against our national interest," Corker said.

Both presidential candidates, Hillary Clinton and Donald Trump, have said they are in favor of the legislation.

Before last week, Obama had previously issued 11 vetoes during his presidency according to Senate records— none of which had been overturned.

In comparison, George W. Bush issued 12 vetoes during his tenure, four of which were overturned during his last two years in office as he saw his popularity plummet. Bill Clinton issued 36 vetoes with two overridden and George H.W. Bush issued 29 vetoes with just one overridden