Amman, Jordan — When the United States Congress voted to override a presidential veto and clear the way for US citizens to sue foreign states for supporting terrorism, it highlighted a major weakness in US-Saudi relations: two allies shifting in opposite directions.

The passage of the Justice Against Sponsors of Terrorism Act (JASTA), as well as mounting concerns over Saudi Arabia’s increased targeting of civilians in Yemen, portray Washington and Riyadh as allies of convenience whose fundamental values clash.

Many members of Congress and Democratic presidential candidate Hillary Clinton are increasingly accusing Saudi Arabia of being an incubator for terror and a human-rights violator. Indeed, Saudi Arabia faces an image problem. Though it has been attacked by the Islamic State six times in the past year and a half, Saudi Arabia's links to hard-line Wahhabi Islam and prominent citizens' support for groups such as Al Qaeda make it a target.

To Saudi eyes, the US is unjustly punishing a key ally. Not only does Saudi Arabia say it is reforming its ties to that extreme interpretation of Islam, but it also sees itself as a pillar in the fight against groups such as the so-called Islamic State.

“Saudi Arabia is already doing a lot to curb extremism and fight terrorism, while maintaining its Wahhabi-based legitimacy,” says Bruce Riedel, a former CIA official and director of Brookings Intelligence Project. “But it is difficult to sell this case to the outside world because it is a nuanced argument – Saudi Arabia is being seen as both the arsonist and the firefighter.”

How the relationship has cooled

From the Saudi perspective, it has been cracking down on ultraconservative preachers and hate speech after becoming a target of Al Qaeda in 2002. That has involved removing and retraining hundreds of clerics and teachers in mosques and schools across the country. More than 1,600 suspected Islamic State supporters have been arrested across the country during the past two years. Since 2003, Riyadh has dismissed more than 3,500 imams for “extremist” views.

Saudi intelligence-sharing has also prevented “multiple” attacks in the US, including an Al Qaeda-planned cargo plane bomb plot in 2010, both Saudi officials and US intelligence analysts say. And Riyadh has closed loopholes allowing individuals to fund Al Qaeda or the Islamic State – forcing jihadists to funnel money through neighboring Kuwait.

But it is believed that private Saudi citizens have financed jihadist militias in Syria. Ultraconservative clerics and imams still preach intolerance, while a ban on women’s driving and women’s inability to travel without the permission of male relatives make Saudi Arabia an “extremist” state, say critics.

With the rise of threats from the Islamic State (also known as ISIS), many Americans are looking to pin the jihadist cult on a tangible actor – and have settled on Saudi Arabia.

“I think that [with] the rise of ISIS and some of the lone-wolf terror attacks we are seeing in the West, people [in the United States] and elsewhere are trying to come up with an answer,” says Fahad Nazar, a former political analyst at the Saudi Embassy in Washington and an analyst at JTG Inc, a Virginia-based consulting firm. “For some, it seems like Saudi Arabia is a convenient answer as they believe ... Saudi Arabia’s export of ideology over the years is a part of it.”

When JASTA was debated in the House, lawmakers took turns berating Saudi Arabia.

"The Saudis, and the Saudi royal family, have been right up to their eyeballs in … supporting the terrorist activity of radical Islamist forces in the Middle East,” Rep. Dana Rohrabacher (R) of California, said at a hearing on May 24.

The strained relationship has been compounded by the difficulty to definitively prove or disprove Saudi officials’ links to groups such as Al Qaeda. Twenty-eight previously classified pages of the 9/11 commission report, released in June, say claims of such links remain “speculative and yet to be independently verified.”

Mrs. Clinton has been one of the most outspoken critics of Saudi Arabia.

She supported JASTA, and after the Orlando massacre in June criticized Saudi Arabia for not doing enough to “stop citizens from funding extremist organizations.” She called on Riyadh to “stop supporting radical schools and mosques … that have set too many young people on a path towards extremism.” (The Orlando attack was carried out by a man who had traveled to Saudi Arabia.)

Where things go from here

The prospect of a Clinton or Donald Trump presidency could only hasten Saudi Arabia's sense that it needs to look elsewhere for allies.

“We would have preferred to remain allies with the Americans, but we have to look to alternatives to the east,” says a Saudi official close to the palace, who is unauthorized to speak to the press.

Saudi has made overtures to China, the largest consumer of Saudi oil and a weapons supplier to Saudi Arabia. But similar attempts to cozy up to Russia have been derailed by oil politics, Moscow’s support for President Bashar al-Assad in Syria, and its aligning with Saudi Arabia’s rival, Iran.

In the near-term, observers say ties between the US and Saudi may be held together by one of its last remaining areas of common interest: arms sales. Under Mr. Obama, the US has provided over $115 billion in arms to Saudi Arabia.

“This US relationship from the Saudi perspective is the most important to their security, and a similar argument can be made for the US – this will not change,” says Mr. Nazer, the JTG analyst.

But the relationship is clearly under pressure. Last week, Saudi involvement Yemen's civil war brought a Saudi missile strike on a funeral hall in the Yemeni capital that left some 140 people dead. The US response was stern.

“In light of this and other recent incidents, we have initiated an immediate review of our already significantly reduced support to the Saudi-led coalition and are prepared to adjust our support so as to better align with US principles, values, and interests, including achieving an immediate and durable end to Yemen's tragic conflict,” National Security Council spokesman Ned Price said in a statement Saturday.

The US-Saudi relationship is coming to terms with “irreconcilable differences,” observers say.

“One of the essential weaknesses of the US-Saudi relations since the beginning was that while we have common interests in confronting Soviet Union, Iran, and now terrorism – we don’t have any common values,” says Mr. Riedel. “Saudi Arabia is an absolute monarchy built on a religious legitimacy with no freedom of press or religion; the US is a democracy that prides itself on those ideals.”