Protesters in Cairo rally against President Obama and in support of Egypt’s then-Defense Minister Abdel Fatah Al-Sissi in July 2013. (Khaled Elfiqi/European Pressphoto Agency)

When he launched his attempt to rebuild U.S. relations with the Muslim world seven years ago, Barack Obama started with Turkey and Egypt, vital U.S. allies that seemed to be on the cusp of change. Under Recep Tayyip Erdogan, Turkey was pioneering a model of moderate, democratic Islamism. Egypt was still ruled by an aging strongman, but with prodding from the George W. Bush administration, it had allowed the flourishing of a liberal civil society and was attempting to modernize its economy.

Since then, the two countries have, indeed, transformed their political systems and their relations with the United States — and the result has been a disaster for U.S. interests. As Obama prepares to leave office, Turkey and Egypt are emerging as twin models for a 21st-century Muslim authoritarianism, one Islamist and one secular. Their regimes are far more repressive than they were in 2009 and far less open to liberal ideas. But their most distinguishing feature, compared with a decade ago, is their anti-Americanism.

Erdogan and Abdel Fatah al-Sissi, Egypt’s general-turned-president, have become certifiably paranoid in their views of the United States. They not only embrace wild anti-American conspiracy theories, but articulate them in public. They seed the media they control with propaganda that makes Vladi­mir Putin’s anti-U.S. diatribes look tame. They go out of their way to persecute civil society groups, politicians and journalists they perceive as having U.S. support or connections.

Sissi, who carried out a coup against an elected Islamist government, blames Washington for that regime’s rise to power and suspects that the U.S. aim remains to destroy the Egyptian state through something he calls “fourth generation war.” Erdogan, an elected Islamist who just put down an attempted military coup, blames the Obama administration for harboring the man he accuses of orchestrating the move against him. One of his cabinet ministers directly accused the United States of sponsoring the coup — and Erdogan hasn’t contradicted him.

Sure, Turkey, a NATO member, still hosts U.S. forces, and Egypt is still one of the largest recipients in the world of U.S. military and economic aid. But those look like relics of bygone relationships — or, in Egypt’s case, the price the United States must pay to avoid a complete breach. As it is, most U.S. economic assistance to Cairo is piling up unspent, because Sissi refuses to allow U.S. funds to flow to nongovernmental organizations he believes are part of the American plot against him. And both Sissi and Erdogan have taken to courting Putin and shopping for Russian weapons.

Fethullah Gulen is an Islamic scholar and cleric from Turkey. He left Turkey in 1999, and is now living in self-imposed exile in Pennsylvania. (Claritza Jimenez,Jason Aldag/The Washington Post)

Putin and China’s Xi Jinping have helped to inspire the new Muslim models of authoritarianism. A decade ago, dictatorship looked untenable in a globalizing world dominated by the United States; consequently, Erdogan was pushing Turkey toward membership in the European Union, while Egyptian strongman Hosni Mubarak was allowing his son to privatize state companies and tolerating Western funding of Egyptian groups promoting democratic politics and the rule of law. Now the Chinese and Russian regimes seem to offer proof that it’s possible to exclude democratic competition, suppress civil society, censor the Internet, practice crony capitalism, defy Washington — and still flourish.

So both Muslim governments are importing those practices. Erdogan has copied Putin’s political path, shifting from prime minister to the presidency while seeking a constitutional reform that would vastly increase the powers of the executive. Since the coup, he has targeted more than 50,000 perceived opponents. Sissi is preparing a draconian law that, like those already passed in Moscow and Beijing, would shut down any NGO with foreign connections or support. Most of these are already closed; U.S. citizen Aya Hijazi, who launched an organization to help impoverished street children, has been imprisoned for two years without trial.

Is all of this Obama’s fault? Of course not. Politics in Egypt and Turkey have been roiled by the failed Arab Spring, the rise of the Islamic State and the megalomania of their rulers, among other forces. But Obama’s attempt to “seek a new beginning between the United States and Muslims,” as he put it in his Cairo address of 2009, manifestly backfired in these strategic countries. An important factor was his inconstancy: His administration veered between backing Mubarak and pushing him out; warning against an Egyptian coup and then endorsing the Sissi regime.

Having first cultivated Erdogan, Obama abruptly dropped him when he began pressing for U.S. intervention in Syria. The first U.S. response to the attempted coup, from Secretary of State John F. Kerry, was strikingly neutral. If Erdogan and Sissi have come to believe in conspiracy theories about the United States, maybe that’s because there’s been no rational way to explain Obama’s behavior.

The 44th president will gratefully walk away from all this in January. His successor will find that the pillars of U.S. engagement in the Middle East for 40 years and more have been replaced by Muslim anchors of an emerging global movement: unfree and anti-American.

Read more from Jackson Diehl’s archive, follow him on Twitter or subscribe to his updates on Facebook.