WASHINGTON (Reuters) - President Barack Obama on Friday vetoed legislation allowing families of victims of the Sept. 11 attacks to sue Saudi Arabia, which could prompt Congress to overturn his decision with a rare veto override, the first of his presidency.

U.S. President Barack Obama walks to the the Oval Office of the White House upon his return to Washington from New York, U.S. September 21, 2016. REUTERS/Yuri Gripas

Obama said the Justice Against Sponsors of Terrorism Act would hurt U.S. national security and harm important alliances, while shifting crucial terrorism-related issues from policy officials into the hands of the courts.

The bill passed the Senate and House of Representatives in reaction to long-running suspicions, denied by Saudi Arabia, that hijackers of the four U.S. jetliners that attacked the United States in 2001 were backed by the Saudi government.

Fifteen of the 19 hijackers were Saudi nationals.

Obama said other countries could use the law, known as JASTA, as an excuse to sue U.S. diplomats, members of the military or companies - even for actions of foreign organizations that had received U.S. aid, equipment or training.

“Removing sovereign immunity in U.S. courts from foreign governments that are not designated as state sponsors of terrorism, based solely on allegations that such foreign governments’ actions abroad had a connection to terrorism-related injuries on U.S. soil, threatens to undermine these longstanding principles that protect the United States, our forces, and our personnel,” Obama said in a statement.

Senator Chuck Schumer, who co-wrote the legislation and has championed it, immediately made clear how difficult it will be for Obama to sustain the veto.

Schumer, the No. 3 Democrat in the Senate, issued a statement within moments of receiving the veto, promising that it would be “swiftly and soundly overturned.” He represents New York, home of most of the Sept. 11 victims.

Both the Democratic and Republican candidates for president, Hillary Clinton and Donald Trump, said they would have signed the bill into law if they were in the White House.

SOME DOUBTS

If two-thirds of the lawmakers in both the Senate and House vote to override, the law would stand, the first such override since he became president in 2009, and possibly the last.

Obama leaves office in January. Friday’s veto was the twelfth of his presidency.

An override has been expected, despite some lawmakers saying they had doubts about the measure.

In a letter seen by Reuters on Friday, Republican Representative Mac Thornberry, chairman of the powerful House Armed Services Committee, said he would oppose the override.

“My primary concern is that this bill increases the risk posed to American military and intelligence personnel, diplomats and others serving our country around the world,” Thornberry wrote in a letter encouraging his fellow Republicans to sustain the veto.

House Speaker Paul Ryan said Wednesday he thought there were enough votes to override a veto, but had concerns. “I worry about trial lawyers trying to get rich off of this. And I do worry about the precedent,” he told reporters.

The “9/11 Families & Survivors United for Justice Against Terrorism” group, which has pressed Congress to uphold the legislation, called Obama’s veto explanation “unconvincing and unsupportable.”

The Saudi government has lobbied heavily to stop the bill, the European Union has formally opposed it and Gulf States have condemned it.

Major U.S. corporations such as General Electric and Dow Chemical have also pressed lawmakers to reconsider.

“The bill is not balanced, sets a dangerous precedent, and has real potential to destabilize vital bilateral relationships and the global economy,” GE Chief Executive Jeffrey Immelt said in a letter to Senate Majority Leader Mitch McConnell, who supports the bill.