After what was likely Obama’s last trip to the region, his Mideast legacy is clear: He has broken eggs, but he’s hardly handing his successor an omelet.

Presidential campaign promises notwithstanding, there’s no going back to Washington’s long-established policy framework in the Middle East. Obama consigned that to the scrap heap when he joined five other major powers in talks to limit Iran’s nuclear program three autumns ago.

The Iran agreement that was finally signed last July was a smart move. But it was inevitable that it would prompt realignments across the region, notably but not only with Saudi Arabia.

The Saudis appear to recognize this, although they’re plainly uncertain of Washington’s intent as the status quo passes. “It is a concerning factor for us if America pulls back,” Turki al-Faisal, a Saudi royal and a former ambassador to the U.S., said last week. “America has changed, we have changed, and definitely we need to realign and readjust our understandings of each other.”

But Obama has made the very worst of his own smart initiatives. By all appearances he either lost his nerve as the larger consequences of the Iran accord began sinking in or he simply wasn’t up to a fundamental renovation of Middle East policy in the first place.

Whoever sits in the White House a year from now will have to go forward more wisely than Obama has. Voters concerned about terrorism and the rise of ISIS should consider this in November: Either the U.S. finds a new way forward in the Middle East or we are in for many more years of disorder, costly military engagement, national security risk, diplomatic friction, and uncertain energy supply.

Since Israel is a constant in American policy, the challenge is to find a new balance in relations with Iran and Saudi Arabia. These two now form an axis of animosity, and the task for Washington is to tread carefully between them.

In the Iran case, Obama and Secretary of State John Kerry always stressed that the nuclear accord wasn’t intended to produce a broader rapprochement. That may be right or wrong—it’s wrong in my view—but it’s another thing altogether to hedge on the agreement itself, as the administration has been doing for some months.

First, Treasury is effectively keeping the most damaging sanctions against Iran in place—alienating not only the reformists in Tehran, who deserve American encouragement, but also the European business community. Neither is able to do the business they anticipated once the agreement took effect.

Second, Treasury’s Office of Foreign Assets Control has imposed two new sets of sanctions against Iran in response to tests of nuclear-capable missiles conducted last autumn and last month. This is a sleight of hand that not even Washington’s partners in the P5 + 1 negotiating group (the permanent members of the Security Council and Germany) appear to countenance.

Until recently the U.S. claimed the missile tests violate a U.N. Security Council resolution forbidding them. They do not. Resolution 2231, submitted by the U.S. and passed unanimously in the council when the nuclear accord was signed last year, supersedes earlier resolutions and merely “calls upon” Iran to avoid testing nuclear-capable missiles.

The softened language, which emerged from intense negotiation, reflects Iran’s right to self-defense. In any case, Iran is now certifiably incapable of making a nuclear warhead.

While the administration has now retreated from its initial charges of Iranian violations, there appears to be no thought of dropping the new sanctions. The takeaway: If Obama set out to derive as little good as possible from the nuclear accord, it’s hard to see how he could have possibly been more successful.

In fairness, it was never going to be easy to get the Saudis to swallow the nuclear accord, given King Salman’s determination to assert Sunni primacy across the region in competition with Shiite Iran. But if a cooler relationship was inevitable, something nearer ice-cold wasn’t.

Obama’s solution, as his visit to Riyadh made crystal clear, simply isn’t working. And from the U.S. perspective, it’s making matters worse.

The administration is now increasing military assistance to the Saudis even as they wage an incautious sectarian war in Yemen. Last month the U.N. warned that Saudi bombing sorties may involve war crimes.

In Syria, Obama is relying on the Saudis as a “regional ally” against the Islamic State, but Riyadh’s ideological support for the Sunni-nationalist ISIS is well established. Is this contradiction supposed to float away simply because it’s inconvenient?

It’s the same problem in Geneva. The Saudi-supported opposition group walked out of talks last week because it continues to insist that the Assad government—which is Alawite, a Shiite sect—has to go before any deal can be struck. While we don’t know what Assad’s counterproposal to form a “unity government” means, it sounds preferable to another Islamic regime that assumes power without elections and governs according to Sharia law.

In effect, the Obama administration has led the U.S. into a dangerous moment in a dangerous region. As the fight against the Islamic State intensifies, it is starting to look as if Obama has too many chips on the Saudis to get this job done.

And if the temperature in U.S.-Saudi relations continues to drop, the potential vulnerability of U.S. oil supplies—only Canada ships more to the U.S. than Saudi Arabia—can only increase.

Never mind the boilerplate about energy independence: Damaging ties with the Saudis is a risk no president should take. The next one will need a lot more diplomatic finesse.

Patrick Smith, a correspondent abroad for many years, is a columnist essayist, critic, and lecturer. His most recent book is Time No Longer: Americans After the American Century. Follow him @psmith7600 or on his web site, patricklawrence.us.