Nearly two dozen House Republicans broke rank on Wednesday and voted to sustain President Barack Obama’s veto of a bill allowing families of victims of terrorism on U.S. soil to sue foreign governments believed to be linked to the attacks.

The vote posed a dilemma for lawmakers with reservations about the bill, because they could be cast as unsympathetic to families of those who died in the 9/11 attacks. And Senate leaders easily mustered the requisite two-thirds supermajority needed to overturn Obama's veto — the first time Congress has done so during his presidency.

The final Senate vote tally was 97-1, with Minority Leader Harry Reid casting the lone dissent.

Proponents of the bill have argued that the legislation could allow families who lost loved ones to sue Saudi Arabia for its alleged ties to the attackers.

The 18 House Republicans and 59 Democrats who voted not to override the veto said they shared the president’s legal and diplomatic concerns about the measure, including putting military personnel at risk abroad. One issue is the legislation's effect on sovereign immunity, which the White House says has long protected the U.S., its military personnel, government officials and corporations abroad.

A “Dear Colleague” letter by House Armed Services Chairman Mac Thornberry was circulated by public relations agents working on behalf of the Saudi embassy. The Texas Republican wrote that the bill “takes a major step toward eroding the doctrine of sovereign immunity.”

Thornberry was joined by Washington Rep. Adam Smith, the committee’s ranking Democrat. Both voted to sustain the veto.

“Taking this policy path will end up doing the United States more harm than good,” Smith wrote in a separate letter. “We have far more at stake as a result, and it is our personnel who will incur the most risk if we erode their legal protections.”

Other Republicans siding with Obama included Reps. Jason Chaffetz of Utah, Darrell Issa of California, Steve King of Iowa, David Jolly of Florida and Reid Ribble of Wisconsin.

Obama has argued that the law could spur other nations to pass reciprocal measures, making U.S. service members, including those supporting counterterrorism efforts, vulnerable to accusations that their activities contributed to illegal acts.

Rep. John Fleming, a Louisiana Republican who also serves on the Armed Services committee, said GOP members were briefed this week about such implications.

“We certainly don’t want to put our servicemen and women in any jeopardy overseas,” said Fleming, who voted to override the veto. “Still, I think as the evidence has come forward to suggest that there were Saudis who were helping in the 9/11 attack, that they be subject to some sort of financial penalty.”

Some House Democrats said their support of the legislation, known as the Justice Against Sponsors of Terrorism Act, demonstrated its merits. Proponents say the measure is narrowly written, and that the U.S. has little to fear because it doesn't sponsor terrorist attacks.

“When you’re contemplating overriding a veto of the president of your own party, you understand the gravity of that,” Virginia Rep. Gerald E. Connolly told Roll Call last week.

Opponents of the bill, which has been in the works since 2009, have said there could be an effort to develop a legislative fix after it becomes law. One option is introducing legislation during the lame-duck work period later this year to make the bill applicable only to the Sept. 11 attacks.

Twenty-eight senators including the leaders of the Foreign Relations and Armed Services committees signed a letter to Senate Majority Whip John Cornyn of Texas and Democratic Sen. Charles E. Schumer of New York, asking them to work in “a constructive manner to appropriately mitigate those unintended consequences” of the bill.

Texas GOP Rep. Pete Sessions said after the House vote that he did not agree with Congress’ attempt at an override.

“As you engage sometimes for the reasons that you do, sometimes there are civilians and other people that get caught up,” he said. “It’s just a dangerous slope for us.”

Obama aides downplayed the significance of the veto, portraying the override as election-year politics, with members reluctant to be called soft on terrorism weeks before facing voters. They also contend that overrides have been uncommon under Obama because, as White House spokesman Josh Earnest put it Tuesday: “We haven't seen [former Speaker John A. Boehner] or Speaker [Paul D.] Ryan work effectively with [Senate] Leader [Mitch] McConnell to pass legislation that advances the conservative agenda.”