Barack Obama has vetoed a bill that would have allowed the families of 9/11 victims to sue the government of Saudi Arabia, setting up the possibility the US Congress may override his veto for the first time in his presidency.
Mr Obama's move escalates the fight over an emotional issue that has overlapped with the campaign debate over terrorism and the Middle East.
The bill had sailed through both chambers of Congress with bi-partisan support, clearing the final hurdle just days before the 15th anniversary of the September 11 2001 attacks that killed nearly 3,000 people.
The president said the bill, which does not refer specifically to Saudi Arabia, could backfire by opening up the US government and its officials to lawsuits by anyone accusing America of supporting terrorism, rightly or wrongly.
"I have deep sympathy for the families of the victims of the terrorist attacks of September 11 2001," Mr Obama wrote to the Senate in a veto message about the bill, known as the Justice Against Sponsors of Terrorism Act.
But he said: "The JASTA would be detrimental to US national interests more broadly."
Congress is determined to try to overturn the veto, which requires a two-thirds vote in the House of Representatives and Senate. Previous attempts to overturn Mr Obama's vetoes have been unsuccessful.
House minority leader Nancy Pelosi has said an override would pass in the Republican-controlled lower chamber. Yet the Senate would be the greater challenge. After furious lobbying to try to peel off supporters, the White House said on Friday it was unclear whether enough had defected to avert an override.
With politicians eager to return home to campaign, a vote could come early next week. Senate majority leader Mitch McConnell's office said the chamber would vote "as soon as practicable in this work period".
Senator Chuck Schumer of New York, the Senate's number three Democrat and a traditional Obama ally, came out swinging against the president while predicting politicians would reverse it "swiftly and soundly".
"The families of the victims of 9/11 deserve their day in court, and justice for those families shouldn't be thrown overboard because of diplomatic concerns," he said.
A coalition of 9/11 victims' families, meanwhile, said they were "outraged and dismayed".
In a response circulated by their lawyers, the families insisted the bill would deter terrorism, "no matter how much the Saudi lobbying and propaganda machine may argue otherwise".
Though the concept of sovereign immunity generally shields governments from lawsuits, the bill creates an exception that allows foreign governments to be held responsible if they support a terrorist attack that kills US citizens on American soil.
But opponents say it is a slippery slope, considering that the US is frequently accused wrongly by its foes of supporting terrorism.
"Americans are in countries all over the world," House Armed Services Committee chairman Mac Thornberry, a Republican, said in a letter urging colleagues to support a veto.
"Many of those countries do not respect the rule of law and we cannot expect their responses to be as measured and narrow as ours."
Fifteen of the 19 men who carried out the 9/11 attacks were Saudi nationals. Families of the victims spent years lobbying for the right to sue the kingdom in US courts for any role elements of Saudi Arabia's government may have played. Saudi Arabia, a key US ally, strongly objected to the bill.
Mr Obama long had objected, too, warning that foreign countries might reciprocate by dragging American diplomats and military members before courts.
The administration was also apprehensive about undermining a difficult yet strategic relationship with Saudi Arabia. The US relies on the Saudis to counter Iran's influence in the Middle East and help combat the spread of terrorism.