John Avlon is a CNN senior political analyst and anchor. The opinions expressed in this commentary are his own. View more opinion articles on CNN.

(CNN) "He's a son of a bitch, but he's our son of a bitch." President Franklin Delano Roosevelt is said to have been talking about Nicaraguan dictator Anastasio Somoza. It was 1939, and you can imagine him, cigarette and martini in hand, making the case for realpolitik in a world hurtling toward world war.

This strategy is also known as "the enemy of my enemy is my friend." And it's been the source of some of our country's biggest geopolitical blunders. Because whatever the short-term benefits -- and in wartime, they can be considerable -- deals with dictators and other assorted extremist groups end up diminishing America's moral authority and often lay the seeds for the next great conflict.

The downside of this dangerous temptation has reared its head again with Saudi Arabia's brutal murder of Washington Post columnist Jamal Khashoggi, throwing the Trump administration's Middle East strategy into chaos. But it's always been a risky business.

Take Joseph Stalin, for starters. During the Second World War, after the bloody dissolution of the Hitler-Stalin pact, the Soviet Union was engaged in a bloody war on the eastern front as the allies focused on driving Adolf Hitler out of Western Europe. FDR was convinced he could charm the man who had already murdered millions of his own countrymen and joined naïve left-wingers in our country in calling the Soviet's "man of steel" (a translation of "Stalin") the decidedly more jovial "Uncle Joe."

The alliance worked when it came to killing Hitler and his Third Reich. But then came the Yalta Conference and a too-casual carving up of the continent, which left Eastern Europe under Soviet-controlled tyranny for the next 40 years. The Cold War was on.

In the Middle East, many clear-eyed critics point to the 1953 US and British-led overthrow of Iranian Prime Minister Mohammed Mossadegh, who had taken control of the British oil interests. The coup put the Shah of Iran in power but also seeded the violent rise of the ayatollahs a generation later.

Then, the welcoming of the Shah for cancer treatment in the United States spurred the seizure of the US embassy in Tehran and the more than 400-day hostage crisis that dogged the Carter administration. The crisis has been invoked to discredit the United States' interventions and created the regional fault lines we're still contending with today -- including using the Saudis to counterbalance Iran.

Throughout the Cold War, the US backed a rogues' gallery of unsavory characters as a check on communist expansion. They often provided a preferable short-term alternative but the blowback often caused more problems than it solved. In Nicaragua, the brutal Somoza dictatorship dynasty fell to the communist Sandinista National Liberation Front party leaders, who committed crimes of their own (Nicaraguan President and Sandinista leader Daniel Ortega is currently orchestrating a bloody crackdown of his citizens).

US backing of Cuba's Batista created the conditions for the communist Castro regime. And these proxy wars often fueled anti-American sentiment, undercutting our vision of American exceptionalism with accusations of Yankee imperialism.

The long-standing US support of apartheid South Africa -- a dependably anti-communist Western colonial power -- looks inexcusable today, especially the Reagan administration's refusal to back sanctions in the 1980s. Luckily, Nelson Mandela proved to be far wiser and embraced the United States under Bill Clinton upon his release from prison, in an effort to mend the legacy of the apartheid.

High up on the list of bad ideas in the rear-view mirror was the brief US embrace of Iraqi President Saddam Hussein. During the Iran-Iraq war, Hussein was literally the enemy of our enemy, coming just years after the hostage crisis in Iran. He was a brutal dictator but not an Islamist -- a man that the US could do business with -- literally.

There's a now-infamous photo of Donald Rumsfeld -- the once and future defense secretary -- deferentially shaking Hussein's hand as an envoy of then-President Reagan. Rumsfeld, of course, presided over the Pentagon during the second, massively destabilizing war with Iraq and subsequent execution of Hussein. The rise of ISIS and ongoing regional chaos is one result.

Saddam Hussein meets Donald Rumsfeld in Baghdad in 1983.

But perhaps the most brutally ironic example of this strategy was the US backing of the anti-Soviet Afghan rebels known as the mujahideen. The Carter administration directed the CIA to provide backing for the Muslim group they regarded as freedom fighters, especially after the Soviet invasion of Afghanistan.

The book and movie, "Charlie Wilson's War," captured the idealism behind the intervention -- but also the failure to follow through with funding to help solidify the post-state after the Soviets were repelled. Elements of the mujahideen became the Taliban, and one wealthy fighter was a Saudi billionaire's son by the name of Osama bin Laden.

This is more than just a cautionary tale. When past Presidents made deals with shadowy figures, they did so primarily with an eye towards the geopolitical chessboard, struggling between our ideals and realpolitik responsibilities. "Since its founding, America has tried to balance the realism of the world around it with the moralism of its founding ideals," said Stuart Gottlieb, who teaches American foreign policy at Columbia.

"But history shows that whenever it leaned too realist, by, for example, supporting friendly dictators, or too moralist, by undercutting allies based on their human rights record, there was usually some form of blowback that sent the country back in the other direction. It's been a tough balancing act."

But with Donald Trump, it's been a bit different. To be sure, his embrace of Saudi Arabia's Crown Prince, Mohammed Bin Salman, builds on decades of a close but complicated relationship between the kingdom and the United States. They have often been stalwart allies behind the scenes, despite the kingdom's support of policies from the funding of Wahhabist madrassas to repressive treatment of women, which are not in line with US interests and values.

But the Trump administration went all in with the Saudis, seeing them as the key to a larger realignment within the Middle East, where that country could serve as a check on Iran and create the outlines of a new alliance for stability involving Egypt and Israel. They cozied up with the Crown Prince despite brutal treatment of his rivals, isolation of Qatar and support of a cruel war in Yemen.

But what's different is that the Saudi Crown Prince is just one of many strongmen on the world stage that President Trump has hugged close. He seems to have an instinctive affinity for authoritarian figures, from his professed "love" for North Korean dictator Kim Jung Un to praise for the Philippines' leader Rodrigo Duterte's bloody, repressive drug war.

The biggest difference with Donald Trump is that he's been quick to condemn America's past policies not from an idealistic human rights perspective but from a cold realism that is quick to call the United States morally equivalent to other countries, like Russia . No other US president would refuse to condemn Putin's extra-judicial killings by saying, "You think our country's so innocent?"

This echoes a criticism of the United States often made by foreign dictators, who take issue with America's sometimes-moralistic approach to foreign policy, seeing the US as hypocritical do-gooders -- and therefore justifying their own brutality with the belief that everybody does it. In the process, claims of American exceptionalism are eroded in a sea of moral equivalence.

Follow CNN Opinion Join us on Twitter and Facebook

This ignores the many ways in which the US has been an exceptional world power, with all our imperfections. No other nation has fought foreign wars without seeking land other than to bury our dead, as is often said. That's why the Faustian bargains we sometimes make, under the idea that "the enemy of my enemy is my friend," do our nation reputational harm that often outweighs whatever short-term benefits they have provided. It obscures the truth that American patriotism is different from run-of-the-mill nationalism.

As a country based on an idea rather than a tribal identity, our greatest strength comes from a deeper source. As political figures from Joe Biden to Bill Clinton have pointed out, "America's greatest strength is not the example of our power, but the power of our example."