President Donald Trump’s Middle East trip has been a tragedy disguised as farce. Amid the gaffesglowing orbs and gaudy receptions, the Trump administration moved deliberately to take Saudi Arabia’s side in the region’s sectarian struggles and undermine the fragile détente with Iran brought on by the Obama administration’s nuclear deal.

Toadying up to Saudis is morally grotesque but familiar. What now makes it tragic is the obvious lack of strategic payoff. The benefit is negligible and the likely cost is more terrorism and higher chances of a disastrous war with Iran.

Whether Trump bent, bowed or curtsied before King Salman in receiving a gold medal, in policy terms, the trip was an emphatic U.S. bow to the Saudis. Trump praised Saudi counterterrorism efforts without a word of criticism for their funding of Wahhabi extremists around the world. He offered the Saudis a massive $110 billion arms deal despite the fact that their brutal bombing of Yemeni civilians makes it potentially illegal. Trump even adopted the Saudi pretense that their Yemen campaign serves counterterrorism.

The president and two cabinet secretaries awkwardly joined a Saudi sword dance without evident concern for the country’s use of swords to behead people for offenses like political dissent, sorcery and being gay. No administration official criticized the kingdom’s abysmal human rights record whatsoever.

Trump saved his fire for Iran. As Iranian voters delivered a resounding victory for reformists eager to negotiate further openings with the international community, Trump criticized Iran’s animus towards the United States and Israel and aid to terrorists and extremist groups that “spread destruction and chaos across the region.” The hypocrisy of making these remarks alongside the Saudi rulers is remarkable.

For decades, the Saudi regime has funded the establishment of mosques abroad that teach an extreme interpretation of Sunni Islam hostile to Jews and the United States, while often looking the other way when private Saudi donors and charities directly fund terrorist groups like al-Qaida and the Islamic State group. As a classified 2013 State Department cable explained, “donors in Saudi Arabia constitute the most significant source of funding to Sunni terrorist groups worldwide.” Hillary Clinton, in a leaked emails from 2014, wrote that Saudi Arabia was “providing clandestine financial and logistic support to ISIL and other radical Sunni groups in the region.”

By agreeing with the Saudis that Iran is the real source of the region’s problems and rewarding them with an arms deal, the Trump administration just encourages their malfeasance. That’s ironic for a “counterterrorism” mission. But the trip’s effect on Iran may be its biggest blow to U.S. security.

The trouble isn’t so much Trump’s criticism of Iran, which is partly accurate, though ill-timed, but the policy shift it reflects. The regional posture Trump is eager to restore – U.S. friendship with Saudi Arabia and antagonism toward Iran – always rested on shaky reasoning. Changed circumstances have now made that posture more or less deranged.

One reason for that is that Iran is on the U.S.-side in Iraq and Syria, where Iranian-backed militias, including Hezbollah are helping fight the Islamic State group. It’s true that these militias might threaten political reconciliation, but that’s more a reason to work with the Iranians than to shun them.

A second reason to shift stances in the region is change in energy markets. The conventional wisdom that said America should lash itself to the Sauds to ensure steady oil supply followed misapprehensions about global energy markets. Saudi production never turned on U.S. support, and their supply problems were not as big a threat to the U.S. economy as generally thought. Still, to the extent U.S. reliance on Saudi oil production drove the alliance, the shale revolution and increased U.S. energy production undercuts it.

Third, the Iran nuclear deal is a peaceful means to influence Iranian politics, but renewed U.S. antagonism could easily upend it. Iran is not a unified entity. Moderate forces have gained sway in Iran. But Trump’s more antagonistic approach only plays into the narrative of Iranian hardliners wedded to hostile policies. That’s a recipe for undermining the nuclear deal and letting U.S. hawks put us back on the path to war with Iran.

The Trump administration’s plunge to the Saudi side is an unfortunate return to the status quo. Hostility to Iran and friendship with Gulf States is a kind of Washington foreign policy dogma created by a history of hostility on one side and commerce on the other.

In the long term, the U.S. should distance itself from both sides. Our security doesn’t depend on extensive meddling on behalf of any side. For now though, the imperative is to stop kowtowing to the Saudis and antagonizing Tehran. The administration’s present course will only heighten the region’s instability and extremism. Things can always get worse.