It’s after Thanksgiving, and so it bears mentioning that Turkey, under the direction of Recep Tayyip Erdogan, formerly that country’s prime minister and now its president, has apparently lost its mind. Erdogan, a proudly demagogic Islamist, thinks Muslims discovered America, centuries before Columbus got there. Further, he’s built a presidential palace four times the size of Versailles and 30 times the size of the White House.Erdogan’s wildly inflated sense of his own importance underscores both the extent and the source of America’s Turkey problem: The Obama Administration, as well as the Bush White House before it, has failed to cut him down to size. The effects of treating Erdogan like a reasonable actor when he is clearly crazy are not only being felt by the people of Turkey, who have seen their democracy curdle into authoritarian one-man rule and their economic miracle turn into an oligarchical prison-house built on enormous mountains of debt.One familiar target of Erdogan’s public abuse is Israel. And as things head south in Turkey, it is not surprising that the Turkish leader has moved from words to actions. Last week, Israeli authorities rolled up a Hamas cell on the West Bank that was plotting several major operations, including an attack on Teddy Kollek Stadium in Jerusalem. The Hamas cell takes its orders from Hamas commander Saleh al-Arouri, who lives openly in Turkey under Erdogan’s apparent protection.Israeli officials are furious with Ankara. They’re complaining to both the United States and NATO about Turkey’s hosting Arouri, who proudly claimed responsibility for the kidnapping and murder of the three Israeli students this summer that led to 40-day-long war with Hamas in Gaza.Ankara has formally denied the Israeli allegations: “Turkey holds dialog with Hamas,” said one Turkish official, perhaps referring to Arouri’s open presence in Turkey’s capital, “but would not under any circumstances allow a terror group to operate from its territory.” But that’s not true, say U.S. officials, who are less concerned with Hamas than with foreign terrorist organizations fighting in Syria. The White House has accused the Turks of giving safe passage to terrorists from both the Islamic State and Jabhat al-Nusra. So, why not Hamas, too?How did the United States get so involved with such a nutty and dangerous character? President Barack Obama once listed Erdogan as his closest friend among foreign leaders, but it’s not like anyone can claim to be surprised that the Turkish premier is a dangerous jerk. Erdogan has a strong anti-Israel, and perhaps anti-Semitic, bias and can’t keep himself from insulting domestic rivals and foreign actors, friend as well as foe. But U.S. officials have known from the very beginning of his first term as premier in 2003 that both Erdogan and the Justice and Development party he founded would likely constitute a big problem for U.S. interests.As then-U.S. Ambassador to Ankara Eric Edelman wrote in a January 2004 cable: “Erdogan has traits which render him seriously vulnerable to miscalculating the political dynamic, especially in foreign affairs … [his] authoritarian loner streak … prevents growth of a circle of strong and skillful advisers, a broad flow of fresh information to him, or development of effective communications among the party headquarters, government, and parliamentary group.”Nonetheless, the White House Edelman worked for often praised the Justice and Development government as a beacon of Islamist democracy. The Bush Administration even tapped Erdogan to mediate peace talks in 2008 between Syria and Israel. At the time, then-Prime Minister Ehud Olmert was reported to have offered to return the Golan Heights to Damascus, a decision that, in light of the Syrian civil war, might have proven catastrophic for Israel.But Israel has no excuses either. Even before the 2010 Mavi Marmara episode, when a Turkish-flagged ship ferried terrorists to break Israel’s naval blockade of Gaza, it was clear that the AKP was trouble. The massive Ergenekon campaign that sent domestic opponents, especially journalists and senior army officers, to jail on ridiculous charges was all the evidence the United States and Israel needed that Turkey was going in the wrong direction.The big question is, why haven’t U.S. policymakers, from the Bush through the Obama Administrations, been able to wrangle Erdogan and get him to behave according to minimal rules of the road that govern civilized nations—like not sponsoring terror attacks against your neighbors? After all, bigmouths are a dime a dozen in the Middle East. And Obama managed to outflank Israel’s opinionated Prime Minister Benjamin Netanyahu on Iran, which Jerusalem says is a vital, indeed an existential, interest. Administration officials recently boasted about deterring Bibi from striking Iranian nuclear facilities, and now, as one Obama staffer told The Atlantic’s Jeffrey Goldberg, it’s too late for the Israeli prime minister to do anything about it.Obama has also sidelined traditional U.S. allies in the Persian Gulf, like Saudi Arabia and the United Arab Emirates. At the same time, the administration has put the freeze on Egypt’s new President Abdel Fattah al-Sisi by holding on to parts of the annual aid package. Clearly, Erdogan would appear to be a likely candidate for some of the tough love that the White House enjoys dispensing to even its oldest and most trusted allies.Yet, instead of trying to rein in Erdogan and turn him into a useful citizen, the Obama White House gave him too much rope and then crudely pushed him out of the nest. For instance, in 2010 the administration tasked Turkey, along with Brazil, to make a deal with Iran over its nuclear weapons program. The White House criticized the agreement Ankara brokered, largely because it allowed Iran to continue enriching uranium. It’s worth noting that four years later the Obama Administration has not only allowed Iran to continue enriching, but has acknowledged its right to do so.Perhaps most significant, the White House handed its Syria policy to Erdogan when the 2011 uprising against Bashar al-Assad erupted. The problem was not only that Turkey proved incapable of projecting soft power that the Obama Administration had counted on, but also that Erdogan had neutered his own military through the Ergenekon campaign. As Erdogan proved incapable of stopping Assad’s killing machine, either through words or force, a refugee crisis swelled within Turkey’s borders, where terrorists from the Islamic State and Jabhat al-Nusra crossed paths with Assad forces who waged terrorist operations killing Turkish citizens.So, why shouldn’t Ankara back Hamas? Nothing else Erdogan does is working, and it’s good public relations in a region where it’s always a crowd-pleaser to target the Jews. Besides, the White House has implicitly endorsed Hamas as a legitimate interlocutor. First, the administration signed off on the unity deal that brought Hamas into the Palestinian Authority. And then even after Hamas’ Turkish cell (directed by Arouri) on the West Bank crashed the unity government with the kidnappings and murders, the administration still never batted an eye.And why should the United States be upset? After all, its point-man on the peace process Martin Indyk had just cashed a $15 million check from Qatar, Hamas’ main financial backer. Sure, the check was written out to the Brookings Institution, but if the White House didn’t care that its own diplomats were taking money from the main sponsors of Hamas—mortal enemy of both Israel and the PA—why should Erdogan be worried about providing sanctuary to Hamas commanders? The Obama Administration’s treatment of Israel—especially its public flogging of Netanyahu—is all the evidence Erdogan needs that Obama will never exact a cost for hosting Hamas officials who plan terror attacks.By allowing Erdogan to support terror plots against a U.S. ally and write a seemingly endless series of regional bad checks on America’s account, the administration didn’t simply decide to overlook Erdogan’s bad behavior—they endorsed it. Turkey’s mess is simply a reflection of the 20-year mess that is American Middle East policy.***Like this article? Sign up for our Daily Digest to get Tablet Magazine’s new content in your inbox each morning.Lee Smith is the author of The Consequences of Syria.