WASHINGTON (AP) — The Senate acted decisively Wednesday to override President Barack Obama’s veto of Sept. 11 legislation, setting the stage for the contentious bill to become law despite flaws that Obama and top Pentagon officials warn could put U.S. troops and interests at risk.

Five weeks before elections, lawmakers refused to oppose a measure backed by 9/11 families who say they are still seeking justice 15 years after the attacks that killed nearly 3,000 people. The bill permits them to sue the government of Saudi Arabia for the kingdom’s alleged backing of the 19 hijackers who carried out the plot. Saudi Arabia is staunchly opposed to the measure.

Senators voted 97-1 to override Obama’s veto. The lone “no” vote was Senate Minority Leader Harry Reid, D-Nev.

A House vote on Obama’s veto was expected later in the day Wednesday. If the House also overrides, the bill becomes law. During his nearly two terms in office, Obama has never had a veto overridden by Congress.

Despite reversing Obama’s decision, several senators said defects in the bill could open a legal Pandora’s box, triggering lawsuits from people in other countries seeking redress for injuries or deaths caused by military actions in which the U.S. may have had a role.

In a letter delivered Tuesday to Senate leaders, Obama said the bill would erode sovereign immunity principles that prevent foreign litigants “from second-guessing our counterterrorism operations and other actions that we take every day.”

But one of the bill’s leading proponents, Sen. John Cornyn, R-Texas, dismissed Obama’s concerns as “unpersuasive.” Cornyn, the Senate’s No. 2 Republican, and other supporters said the bill is narrowly tailored and applies only to acts of terrorism that occur on U.S. soil.

“This bill is about respecting the voices and rights of American victims,” Cornyn said.

Families of the victims and their attorneys disputed concerns over the legislation as fearmongering aimed at derailing the legislation that they have long urged Congress to pass.

Sen. Ben Cardin of Maryland, one of the Democrats who broke with Obama and voted to override, said “the risks of shielding the perpetrators of terrorism from justice are greater than the risks this legislation may pose to America’s presence around the world.”

The legislation gives victims’ families the right to sue in U.S. court for any role that elements of the Saudi government may have played in the 2001 attacks. Fifteen of the 19 Sept. 11 hijackers were Saudi nationals. Courts would be permitted to waive a claim of foreign sovereign immunity when an act of terrorism occurs inside U.S. borders, according to the terms of the bill.

Still, a group of national-security minded legislators pledged to discuss how to repair problem areas during the upcoming lame-duck session of Congress. But the fact that legislation could pass both chambers of Congress without closer scrutiny left at least a few senators chiding themselves for not examining more closely the bill’s potential ramifications.

The Justice Against Sponsors of Terrorism Act, or JASTA, moved to the floor of the Senate in May and passed by voice vote. The bill cleared the House earlier this month, also by voice vote.

“We didn’t pay much attention to this,” said Sen. Dianne Feinstein of California, the top Democrat on the Senate intelligence committee. “And boy is that ever a lesson learned.”

Obama vetoed the measure last week, telling lawmakers the bill would make the U.S. vulnerable to retaliatory litigation.

In his letter to Reid, the president said other countries could attempt to use JASTA to justify similar immunity exceptions to target U.S. policies and activities that they oppose.

“As a result, our nation and its armed forces, State Department, intelligence officials and others may find themselves subject to lawsuits in foreign courts,” Obama wrote. As an example, U.S. troops, including those involved in counterterrorism operations, “would be vulnerable to accusations that their activities contributed to acts that allegedly violated foreign laws,” the president said.

In a separate letter sent Monday to a senior House member, Defense Secretary Ash Carter described the potential for foreign litigants to seek classified intelligence data and analysis and sensitive operational information to establish their cases in what could be an “intrusive discovery process.”

If the U.S. were sued overseas, a foreign court would decide whether the information should be protected from disclosure, he said in the letter to Rep. Mac Thornberry, R-Texas, chairman of the Armed Services Committee. Paradoxically, the information could be central to a defense against the accusations.

“Disclosure could put the United States in the difficult position of choosing between disclosing classified or otherwise sensitive information or suffering adverse rulings and potentially large damage awards for our refusal to do so,” Carter wrote.

Sen. Bob Corker, R-Tenn., voiced his numerous concerns with the bill before the vote but decided to override the president’s veto anyway.

“I do so understanding that there could be in fact unintended consequences that work against our national interests,” said Corker, the chairman of the Senate Foreign Relations Committee.

Missing the vote were Sens. Bernie Sanders, I-Vt., and Tim Kaine, D-Va.

___

Follow Richard Lardner on Twitter: http://twitter.com/rplardner