The death of King Abdullah provides a good opportunity to reflect on the long and troubled relationship between the U.S. and Saudi Arabia.

It is not, by any stretch, an obvious or easy or natural alliance. The U.S. is the land of the free; Saudi Arabia is one of the most repressive societies on the planet, a country where not only do the people have no say in the selection of their leaders but where bloggers are flogged and women are prevented from driving. The U.S. is animated by Enlightenment ideals, Saudi Arabia by the fundamentalist Wahhabi strain of Islam.

Yet since the 1940s the fortunes of these two countries have been closely linked. For many years the relationship could be described simply as: The Saudis give us oil, we give the Saudis security. This is still, for the most part, true. Even if our reliance on Saudi oil is down and we have become more energy self-sufficient, Saudi Arabia is still the second-largest source of imported oil in the U.S. after Canada. And Saudi Arabia still very much depends on American weapons, American military advisers, and ultimately an implicit American security guarantee, manifested when President George H.W. Bush sent troops to the Kingdom in 1990 to defend it against Iraqi aggression.

A few events, in more recent years, have greatly complicated the relationship. First, of course, was 9/11: 15 out of 19 hijackers were Saudis as was the leader of al-Qaeda–Osama bin Laden. This revealed the malignant consequences of the Saudis’ fundamentalist ideology, which gave rise to the world’s most dangerous terrorist group. But when al-Qaeda began to target Saudi Arabia, the Saudis fought back, mobilizing their highly effective bureaucracy of repression to stamp out terrorist attacks. This more or less restored the Saudis to American good graces.

Then a decade after 9/11 came the Arab Spring. With change sweeping the Middle East, the Saudis emerged as the primary champions of repressive stability, playing a role similar to that of the Holy Alliance (Russia, Austria, Prussia) which put down liberal uprisings in Europe in the 19th century. The Saudis even sent their troops into neighboring Bahrain to stamp out Shiite protests, much like the tsar sending his army into Hungary to maintain Austrian rule during the revolutions of 1848. This offended American sensibilities but did not seriously disturb the alliance because the U.S. was also ambivalent about the Arab Spring uprisings, as evidence by our confused policy toward Egypt.

Now, however, a very different and potentially more serious rift is growing between the U.S. and Saudi Arabia over relations with Iran. President Obama is intent on an entente with Tehran. He is desperate for a deal over Iran’s nuclear program that will prepare the way for a broader realignment in the Middle East where Iran could become a partner, rather than an adversary, of the U.S. This is evident in the fact that the U.S. is doing so little to oppose Iranian imperial expansion in Lebanon, Syria, Iraq, and Yemen, among other places, where the Obama administration naively sees Iran and its proxies as allies against ISIS and al-Qaeda.

The Saudis have a very different view. They hate Iran not only because it is a Shiite state and therefore composed of infidels in the eyes of pious Wahhabis but also because Iran is a revolutionary, expansionist state that is challenging Sunni power throughout the region. And Saudi Arabia, as the richest and largest of the Gulf oil kingdoms, has long seen itself as the primary Sunni champion. Thus the Saudis sponsor proxies in Iraq, Syria, Lebanon, and Yemen to wage war on Iran and its proxies. Unfortunately suspicion is rife that some of those who have received Saudi support include jihadists such as ISIS and the al-Nusra Front.

The Saudis are apoplectic that President Obama is flirting with the Iranian mullahs. They want the U.S. to bomb Iran, not to make a deal with it. And they want the U.S. to take tougher action against Iranian proxies such as Bashar Assad, not to reach deals and understandings with them as Obama has done.

Much as it pains me to say it, my country is wrong and Saudi Arabia is right. Obama’s outreach to Iran will not succeed; Iranian revolutionaries who still chant “Death to America” will not make common cause with us. And the price of flirting with them is to drive Sunnis, especially in Iraq, Syria, and Yemen, further into the camp of the jihadists.

From a moral standpoint, admittedly, there is little to choose from between Saudi Arabia and Iran: both are despotic theocracies that are anathema to American values. But from a strategic standpoint, Iran is much more of a threat to the U.S. and our allies.

A useful analogy here is World War II where we had to choose an alliance with the lesser evil (Stalin) to defeat the greater evil (Hitler). It would have made no sense to go the other way, as some on the far-right were advocating in the 1930s; in other words, to team up with Hitler against Stalin. Yet that is akin to what Obama is trying to do today. He would be better advised to hold his nose and restore closer ties with the Saudis, who, however odious, are still a better bet than the Iranians.