The House and Senate voted overwhelmingly Wednesday to undo President Obama’s veto of legislation that would allow lawsuits against foreign governments that sponsor terrorism, giving the president his first veto override since he took office.

The Senate vote was 97-1, with only Democratic Leader Harry Reid voting to sustain the veto. Sen. Tim Kaine, the Democrats’ vice presidential candidate, and Sen. Bernie Sanders were not present to cast votes. The House followed suit a short time later, voting 348-77 to override.

The legislation, known as the Justice Against Sponsors of Terrorism Act, or JASTA, was sponsored by New York Sen. Chuck Schumer, who’s poised to become the Democratic leader in the Senate next year, and Texas Sen. John Cornyn, the second-ranking Republican leader.

The White House lobbied lawmakers and Capitol Hill staff members for weeks, arguing that while Obama supports 9/11 victims and their families – who are eager to sue Saudi Arabia for its alleged role in the terrorist attacks -- the legislation created risks more broadly for U.S. personnel and imperils international policies and protections around the world.

Obama, speaking at a CNN town hall on Wednesday, called the override "a mistake" because “if we eliminate this notion of sovereign immunity, then our men and women in uniform around the world could potentially start seeing ourselves subject to reciprocal laws."

He said he understands why Congress passed the bill, noting that “all of us still carry the scars and trauma of 9/11."

However, he continued, “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 in which we're suddenly exposed to liabilities for all the work that we're doing all around the world."

According to a press pool report from Air Force One Wednesday afternoon -- prior to the House taking action -- White House press secretary Josh Earnest called the override vote “the single most embarrassing thing the United States Senate has done possibly since 1983.” He said the lawmakers’ action was “an abdication of their basic responsibilities as elected representatives of the American people. Ultimately these senators are going to have to answer their own conscience and their constituents as they account for their actions today.”

Schumer said after the vote that the upper chamber did not take the override “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.

“The White House and the executive branch is far more interested in diplomatic considerations. We’re more interested in the families and in justice,” he added. “I think our administration was just dead wrong on this issue."

There have been furious lobbying efforts both in support of and in opposition to the legislation in recent months. Senators felt intense pressure to pass the legislation after a very public push from family members of 9/11 victims. The Saudi government also heavily lobbied Congress to sustain the president’s veto, according to the New York Times, and even threatened to sell off hundreds of billions of dollars in American assets if JASTA becomes law, though some lawmakers consider that to be an empty threat.

Sen. Lindsey Graham, who voted to override the veto but has serious concerns about the legislation, said he didn’t want Saudi Arabia, a key ally of the U.S. in the Middle East, to view Wednesday’s vote as Congress implicating them in the 9/11 attacks.

“I’m worried, like a lot of other people are worried, that Saudi Arabia will see this as the Congress finding them guilty of being involved in 9/11,” Graham told reporters before the vote.

Schumer, however, dismissed those arguments: “If the Saudis were culpable, they should be held accountable. If they had nothing to do with 9/11, they have nothing to fear.”

Though the legislation passed the Senate unanimously in May, several lawmakers began having serious reservations about its long-term implications in recent weeks. Sen. Bob Corker, the chairman of the Foreign Relations Committee, said he had concerns about U.S. sovereignty abroad, and about “outsourcing U.S. foreign policy to trial lawyers.”

Corker voted in favor of the override despite those concerns, but he and other senators have had discussions about approaching the issue again either during the lame-duck Senate session after the election or sometime next year. Graham said there is a group of about 20 senators prepared to re-examine the legislation when Congress returns after the election, and predicted that number could grow. He said he had held “brief” conversations with the bill’s sponsors, about those efforts.

“The focus now is: How can we, over a period of time, create some corrective legislation to deal with whatever blowback may occur?” Corker told reporters Tuesday. “… It’s a group of people that on one hand have empathy for the 9/11 victims, but on the other hand understand that some of the language in this bill could create issues for ourselves.”

Cornyn, however, dismissed the need for any attempt to re-examine a bill that passed with such overwhelming support.

In the House, Minority Leader Nancy Pelosi told reporters Tuesday that she met recently with 9/11 families "and they want their day in court and I want them to have it.” She downplayed the rift between Obama and Capitol Hill Democrats despite the overwhelming margin by which they overrode his veto, the first such action in his nearly eight years in office.

“I wouldn’t make anything big about this between Democrats in the Congress and the president,” she said. “I think that’s overblown."

Alexis Simendinger contributed to this report.