WASHINGTON — The White House saw it coming, but still it stung.

When President Barack Obama was hit with the first veto override of his two terms, it was a clear reminder of his dwindling political influence, years of confounding relationships with Congress and shaky prospects for the few legislative priorities he has left.

The fiercely competitive president has said he intends to keep working with Congress until the final buzzer sounds in January, but it’s not clear how much juice he’ll have left.

Senate Minority Leader Harry Reid of Nevada was the only one among 44 Democrats in the Senate to stand by Obama in upholding his veto of a piece of Sept. 11 legislation.

Every Republican voted on Wednesday to override.

The Republican-led House followed suit, eagerly exceeding the two-thirds threshold necessary to push the legislation into law over the president’s objections. Several lawmakers acknowledged they had problems with the bill, but charged ahead anyway.

On Thursday, Senate Majority Leader Mitch McConnell said lawmakers should consider fixing the measure and that the White House was slow to raise concerns.

No modern president has made it through two full terms without Congress overriding at least one of his vetoes. Obama’s record measures up well compared with his two immediate predecessors. George W. Bush had four and Bill Clinton two.

When a reporter noted that the 97-1 vote was the widest margin for an override vote since 1983, White House spokesman Josh Earnest retorted: “I would venture to say that this is the single most embarrassing thing that the United States Senate has done, possibly, since 1983.”

Obama delivered a more measured, but still harsh, assessment.

“It was basically a political vote,” Obama told CNN, not sparing Democrats from his critique. “Sometimes you have to do what’s hard. And, frankly, I wish Congress here had done what’s hard. … But I didn’t expect it.”

The long-stalled bill, which allows the families of Sept. 11 victims to sue the government of Saudi Arabia for the kingdom’s alleged backing of the attackers, has long flown under the radar. The measure was kept alive by a committed group of families, despite firm opposition from the Saudi government and many in the national security establishment.

The Senate passed the bill in May and the House followed on Sept. 9, two days before the 15th anniversary of the 2001 attacks and a little more than a week before two new bombing plots in the New York and New Jersey area.

Lawmakers found themselves faced with the choice of siding with Saudi Arabia or the sympathetic and organized group of Sept. 11 families. They overwhelmingly sided with the families.

Doing so meant ignoring warnings from a president whose popularity has only inched up as he nears his term. It also meant rebuffing national security officials, who argued that the legislation will set a dangerous precedent that could endanger military personnel and diplomats serving overseas.

Democrats said the override votes weren’t personal. Some did revive an oft-repeated complaint about Obama’s approach to dealing with Congress. Lawmakers and aides described the White House lobbying effort as insufficient and noted it seemed to miscalculate support for the bill in the House.

Although several Democrats and Republicans publicly acknowledged problems with the legislation, the White House appeared unwilling or unable to broker changes.

“This whole thing just kind of continued on with no real involvement as if somehow through osmosis this thing was going to die of its own weight,” said Sen. Bob Corker, R-Tenn. He outlined his “tremendous reservations” with the legislation, but voted to override Obama’s veto anyway.

McConnell, R-Ky., blamed the White House, saying it was too slow to warn about the “potential consequences” of the measure.

The White House dismissed cited what it said was the knotted logic of lawmakers blaming the president for failing to stop legislation he opposed and they supported. White House officials said they did their best to lobby against the measure, but also saw the politics clearly and early, leaving little hope for persuading lawmakers to take a tough vote in an election year.

Obama has much higher hopes for persuading them to take a tough vote after the election. His top priority of the postelection congressional session is the Trans-Pacific Partnership free trade deal, a legacy-making agreement that has taken a beating amid campaign-year complaints about globalization. The deal needs support from both Democrats and Republicans to pass.

Associated Press writers Andrew Taylor, Erica Werner and Richard Lardner contributed to this report.